diff --git a/src/core/catalog.js b/src/core/catalog.js index 3f73e6d91..6e183d964 100644 --- a/src/core/catalog.js +++ b/src/core/catalog.js @@ -1628,18 +1628,20 @@ class Catalog { /* xref = */ null, /* skipContent = */ true ); - const { rawFilename } = fs.serializable; - url = rawFilename; + ({ rawFilename: url } = fs.serializable); } else if (typeof urlDict === "string") { url = urlDict; + } else { + break; } // NOTE: the destination is relative to the *remote* document. const remoteDest = fetchRemoteDest(action); - if (remoteDest && typeof url === "string") { + if (remoteDest) { // NOTE: We don't use the `updateUrlHash` function here, since - // the `createValidAbsoluteUrl` function (see below) already - // handles parsing and validation of the final URL. + // the `createValidAbsoluteUrl` function (see below) already handles + // parsing/validation of the final URL and manual splitting also + // ensures that the `unsafeUrl` property will be available/correct. url = /* baseUrl = */ url.split("#", 1)[0] + "#" + remoteDest; } // The 'NewWindow' property, equal to `LinkTarget.BLANK`. diff --git a/src/core/file_spec.js b/src/core/file_spec.js index d331af04e..6e544295d 100644 --- a/src/core/file_spec.js +++ b/src/core/file_spec.js @@ -18,21 +18,13 @@ import { BaseStream } from "./base_stream.js"; import { Dict } from "./primitives.js"; function pickPlatformItem(dict) { - if (!(dict instanceof Dict)) { - return null; - } - // Look for the filename in this order: - // UF, F, Unix, Mac, DOS - if (dict.has("UF")) { - return dict.get("UF"); - } else if (dict.has("F")) { - return dict.get("F"); - } else if (dict.has("Unix")) { - return dict.get("Unix"); - } else if (dict.has("Mac")) { - return dict.get("Mac"); - } else if (dict.has("DOS")) { - return dict.get("DOS"); + if (dict instanceof Dict) { + // Look for the filename in this order: UF, F, Unix, Mac, DOS + for (const key of ["UF", "F", "Unix", "Mac", "DOS"]) { + if (dict.has(key)) { + return dict.get(key); + } + } } return null; }