Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
fix(index): normalize and concat paths via path.join()
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and michael-ciniawsky committed Feb 20, 2018
1 parent 4c1ccaa commit 26e47ca
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export default function loader(content) {
const relativePath = relativeUrl && `${path.dirname(relativeUrl)}/`;
// eslint-disable-next-line no-bitwise
if (~relativePath.indexOf('../')) {
outputPath = path.posix.join(outputPath, relativePath, url);
outputPath = path.join(outputPath, relativePath, url);
} else {
outputPath = relativePath + url;
outputPath = path.join(relativePath, url);
}
}

Expand All @@ -43,7 +43,7 @@ export default function loader(content) {
if (options.publicPath !== undefined) {
// support functions as publicPath to generate them dynamically
publicPath = JSON.stringify(
typeof options.publicPath === 'function' ? options.publicPath(url) : options.publicPath + url,
typeof options.publicPath === 'function' ? options.publicPath(url) : path.join(options.publicPath || '', url),
);
} else {
publicPath = `__webpack_public_path__ + ${JSON.stringify(outputPath)}`;
Expand Down
2 changes: 1 addition & 1 deletion test/options/__snapshots__/outputPath.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Object {
"assets": Array [
"output_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
],
"source": "module.exports = \\"public_path9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/options/__snapshots__/publicPath.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Object {
"assets": Array [
"9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
],
"source": "module.exports = \\"public_path9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
}
`;
4 changes: 2 additions & 2 deletions test/options/__snapshots__/useRelativePath.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Object {
exports[`Options useRelativePath \`true\` with relative \`context\` 1`] = `
Object {
"assets": Array [
"./9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
"9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
],
"source": "module.exports = __webpack_public_path__ + \\"./9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
"source": "module.exports = __webpack_public_path__ + \\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
}
`;

0 comments on commit 26e47ca

Please sign in to comment.