From 95093a5276d9e627717aa25411284727f312fad5 Mon Sep 17 00:00:00 2001 From: Christian Myksvoll Date: Thu, 13 Jul 2017 22:48:04 +0200 Subject: [PATCH] Check for undefined url (#8640) * Check for undefined new URL(file, window.location.href) throws the following error in IE11 + iPad Safari: Unable to get property 'replace' of undefined or null reference * Adapting previous change to pdf.js code standards Added curly braces * Moved check for undefined above try/catch --- web/app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/app.js b/web/app.js index ff7e5d912..66bacb9a5 100644 --- a/web/app.js +++ b/web/app.js @@ -1403,6 +1403,9 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { const HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io']; validateFileURL = function validateFileURL(file) { + if (file === undefined) { + return; + } try { let viewerOrigin = new URL(window.location.href).origin || 'null'; if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {