Skip to content

Commit 518edfb

Browse files
committed
LinkWizard: fix multilevel parents in references
1 parent 9085b15 commit 518edfb

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/scripts/linkwiz.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class LinkWizard {
398398
// namespaces are irrelevant
399399
} else if (commonPrefixLength < sourceNs.length) {
400400
// add .. for each missing namespace from common to the target
401-
relativeID.push('..'.repeat(sourceNs.length - commonPrefixLength));
401+
relativeID.push(...Array(sourceNs.length - commonPrefixLength).fill('..'));
402402
} else {
403403
// target is below common prefix, add .
404404
relativeID.push('.');

lib/scripts/linkwiz.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function runLinkWizardTests() {
1717
{ ref: 'a', id: 'a:b:c', expected: 'a:b:c' },
1818
{ ref: 'a:b', id: 'c:d', expected: 'c:d' },
1919
{ ref: 'a:b:c', id: 'a:d:e', expected: '..:d:e' },
20+
{ ref: 'a:b:c:d', id: 'a:d:e', expected: '..:..:d:e' },
2021
{ ref: 'a:b', id: 'c', expected: ':c' },
2122
];
2223

0 commit comments

Comments
 (0)