mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Merge pull request #7341 from Snuffleupagus/getDestinationHash-Array
[api-minor] Improve handling of links that are using explicit destination arrays
This commit is contained in:
commit
f97d52182a
10 changed files with 201 additions and 44 deletions
|
@ -757,9 +757,17 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
|
|||
if (isName(remoteDest)) {
|
||||
remoteDest = remoteDest.name;
|
||||
}
|
||||
if (isString(remoteDest) && isString(url)) {
|
||||
if (isString(url)) {
|
||||
var baseUrl = url.split('#')[0];
|
||||
url = baseUrl + '#' + remoteDest;
|
||||
if (isString(remoteDest)) {
|
||||
// In practice, a named destination may contain only a number.
|
||||
// If that happens, use the '#nameddest=' form to avoid the link
|
||||
// redirecting to a page, instead of the correct destination.
|
||||
url = baseUrl + '#' +
|
||||
(/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
|
||||
} else if (isArray(remoteDest)) {
|
||||
url = baseUrl + '#' + JSON.stringify(remoteDest);
|
||||
}
|
||||
}
|
||||
}
|
||||
// The 'NewWindow' property, equal to `LinkTarget.BLANK`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue