diff --git a/src/lib/paths.js b/src/lib/paths.js index 8409184..eef8ef8 100644 --- a/src/lib/paths.js +++ b/src/lib/paths.js @@ -23,7 +23,8 @@ const isUrlWithoutPathname = (assetUrl) => { return assetUrl[0] === '#' || assetUrl.indexOf('%23') === 0 || assetUrl.indexOf('data:') === 0 - || /^[a-z]+:\/\//.test(assetUrl); + || /^[a-z]+:\/\//.test(assetUrl) + || /^\/\//.test(assetUrl); }; /** diff --git a/test/lib/paths.js b/test/lib/paths.js index 47c1398..3421759 100644 --- a/test/lib/paths.js +++ b/test/lib/paths.js @@ -16,6 +16,21 @@ describe('paths', () => { ].every(isUrlShouldBeIgnored)); }); + it('should ignore some urls with basePath', () => { + const isUrlShouldBeIgnored = (url) => + paths.isUrlShouldBeIgnored(url, { + basePath: ['/path'] + }); + + assert.ok([ + '#hash', + '%23encodedHash', + '//somecdnpath.com/asset.png', + 'data:someDataInlined', + 'https://somecdnpath.com/asset.png' + ].every(isUrlShouldBeIgnored)); + }); + it('should\'t ignore absolute urls if have basePath', () => { assert.notOk(paths.isUrlShouldBeIgnored('/absoluteUrl', { basePath: ['/path']