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:
Tim van der Meij 2016-06-09 00:29:10 +02:00
commit f97d52182a
10 changed files with 201 additions and 44 deletions

View file

@ -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`.