mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-02-08 00:21:11 +01:00
Reduce duplication in the pickPlatformItem helper function
Also, tweak code/comment used when handling "GoToR" destinations.
This commit is contained in:
parent
95f62f3b33
commit
84b5866853
@ -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`.
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user