diff --git a/src/utility.js b/src/utility.js index 8b750bd..72d9619 100644 --- a/src/utility.js +++ b/src/utility.js @@ -30,6 +30,7 @@ export function joinPaths(paths) { * @returns {string} */ export function stripTopPath(path, stripPath) { + stripPath = normalisePath(stripPath || ''); if (path === stripPath) { return ''; } diff --git a/test/utility.test.js b/test/utility.test.js index aad68f9..b8eb554 100644 --- a/test/utility.test.js +++ b/test/utility.test.js @@ -16,9 +16,14 @@ test('joins paths', (t) => { test('strips top path', (t) => { t.is(stripTopPath('src/content/index.html', 'src'), 'content/index.html'); + t.is(stripTopPath('src/content/index.html', 'src/'), 'content/index.html'); + t.is(stripTopPath('src/content/index.html', '/src'), 'content/index.html'); + t.is(stripTopPath('src/content/index.html', '/src/'), 'content/index.html'); + t.is(stripTopPath('src/content/index.html', '/src/'), 'content/index.html'); t.is(stripTopPath('src/index.html', 'src'), 'index.html'); t.is(stripTopPath('src/index.html', ''), 'src/index.html'); t.is(stripTopPath('src', 'src'), ''); + t.is(stripTopPath('src', '/src/'), ''); t.is(stripTopPath('src', ''), 'src'); t.is(stripTopPath('sauce/content', 'sauce'), 'content');