diff --git a/src/resolve-path.js b/src/resolve-path.js index 61164af..2a692e3 100644 --- a/src/resolve-path.js +++ b/src/resolve-path.js @@ -10,11 +10,9 @@ async function resolvePath(request) { current = current.replace(/^jspm:/, ''); if (!current.match(/\.s(c|a)ss/)) current += '.scss'; // we need the parent, if the module of the file is not a primary install - let parent = `${System.baseURL}${request.options.urlBase}`; - // when adding urls, some unwanted double slashes may occur - if (System.baseURL.slice(-1) === '/' && request.options.urlBase.slice(0, 1) === '/') { - parent = `${System.baseURL}${request.options.urlBase.slice(1)}`; - } + const parentURL = url.parse(System.baseURL); + parentURL.pathname = request.options.urlBase; + const parent = url.format(parentURL); const file = await System.normalize(current, parent); return file.replace(/\.js$|\.ts$/, ''); } diff --git a/test/resolve-path-test.js b/test/resolve-path-test.js index 1524ab3..8cd91a0 100644 --- a/test/resolve-path-test.js +++ b/test/resolve-path-test.js @@ -70,7 +70,7 @@ describe('resolve-path', () => { const request = { current: 'jspm:indirect-package/mock-asset', previous: 'stdin', - options: { urlBase: '/jspm_packages/npm/mock-package@1.0.0/' }, + options: { urlBase: url.parse(`${__dirname}/jspm_packages/npm/mock-package@1.0.0/`).path }, }; const p = await resolvePath(request, '/'); // System.normalize in resolvePath will give us the absolute path