Skip to content

Commit

Permalink
LinkWizard: fix multilevel parents in references
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed Oct 21, 2024
1 parent 9085b15 commit 518edfb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/scripts/linkwiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class LinkWizard {
// namespaces are irrelevant
} else if (commonPrefixLength < sourceNs.length) {
// add .. for each missing namespace from common to the target
relativeID.push('..'.repeat(sourceNs.length - commonPrefixLength));
relativeID.push(...Array(sourceNs.length - commonPrefixLength).fill('..'));
} else {
// target is below common prefix, add .
relativeID.push('.');
Expand Down
1 change: 1 addition & 0 deletions lib/scripts/linkwiz.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function runLinkWizardTests() {
{ ref: 'a', id: 'a:b:c', expected: 'a:b:c' },
{ ref: 'a:b', id: 'c:d', expected: 'c:d' },
{ ref: 'a:b:c', id: 'a:d:e', expected: '..:d:e' },
{ ref: 'a:b:c:d', id: 'a:d:e', expected: '..:..:d:e' },
{ ref: 'a:b', id: 'c', expected: ':c' },
];

Expand Down

0 comments on commit 518edfb

Please sign in to comment.