diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index d34ef38999..cd0c1d7f08 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -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('.'); diff --git a/lib/scripts/linkwiz.test.js b/lib/scripts/linkwiz.test.js index 2f4b7aed90..44ebbe576d 100644 --- a/lib/scripts/linkwiz.test.js +++ b/lib/scripts/linkwiz.test.js @@ -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' }, ];