Browse Source

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
Christian Myksvoll 8 years ago committed by Brendan Dahl
parent
commit
95093a5276
  1. 3
      web/app.js

3
web/app.js

@ -1403,6 +1403,9 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { @@ -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) {

Loading…
Cancel
Save