diff --git a/lib/partial-build-extension.js b/lib/partial-build-extension.js index 3a2d40b..a1dbee6 100644 --- a/lib/partial-build-extension.js +++ b/lib/partial-build-extension.js @@ -122,7 +122,7 @@ function resolveAuthorUrl (dir) { return '.' } const relpath = ospath.relative(gitRoot, dir) - const segments = (relpath.match(/path.sep/g) || []).length + 1 + const segments = [...relpath].filter((c) => c === ospath.sep).length + 1 return '.' + '/..'.repeat(segments) } diff --git a/test/partial-build-extension-test.js b/test/partial-build-extension-test.js index 5660357..591d63a 100644 --- a/test/partial-build-extension-test.js +++ b/test/partial-build-extension-test.js @@ -181,6 +181,18 @@ describe('partial-build-extension', () => { }) }) + it('should rewrite content sources if refname is HEAD and playbook in grandchild dir', async () => { + const playBookDir = ospath.join(WORK_DIR, 'docs/src/main/antora') + await fsp.mkdir(playBookDir, { recursive: true }) + await fsp.mkdir(ospath.join(WORK_DIR, '.git'), { recursive: true }) + await runScenario({ + refname: 'HEAD', + version: '6.1.0-SNAPSHOT', + expectedRefs: { branches: ['HEAD'], tags: [], url: './../../../..' }, + playbookDir: playBookDir, + }) + }) + it('should rewrite content sources when SNAPSHOT version not found if refname is HEAD', async () => { const playBookDir = WORK_DIR await fsp.mkdir(ospath.join(WORK_DIR, '.git'), { recursive: true })