From 86183499a736ca48df99025e5b60b68a72b62fc9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Wed, 17 Apr 2019 13:23:13 +0200 Subject: [PATCH] Photoviewer: Fix warnings flood Accept https and check for the match of the regexp, fixing: rc:/PhotoViewerCore/script/script.mjs:61: TypeError: Cannot read property '1' of null qrc:/PhotoViewerCore/script/script.mjs:61: TypeError: Cannot read property '1' of null qrc:/PhotoViewerCore/script/script.mjs:61: TypeError: Cannot read property '1' of null qrc:/PhotoViewerCore/script/script.mjs:61: TypeError: Cannot read property '1' of null qrc:/PhotoViewerCore/script/script.mjs:61: TypeError: Cannot read property '1' of null qrc:/PhotoViewerCore/script/script.mjs:61: TypeError: Cannot read property '1' of null Fixes: QTBUG-75255 Change-Id: I3c447830874d504213276b8064abcf3cef1f72ec Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- examples/demos/photoviewer/PhotoViewerCore/script/script.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/demos/photoviewer/PhotoViewerCore/script/script.mjs b/examples/demos/photoviewer/PhotoViewerCore/script/script.mjs index 1eb7cac7..a1822197 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/script/script.mjs +++ b/examples/demos/photoviewer/PhotoViewerCore/script/script.mjs @@ -57,8 +57,9 @@ export function getHeight(string) { } export function getImagePath(string) { - var pattern = /src=\"http:\/\/(\S+)\"/ - return (string.match(pattern))[1] + var pattern = /src=\"https?:\/\/(\S+)\"/ + var match = string.match(pattern) + return match ? match[1] : "" } export function calculateScale(width, height, cellSize) { -- GitLab