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

Commit 26e47ca

Browse files
evilebottnawimichael-ciniawsky
evilebottnawi
authored andcommittedFeb 20, 2018
fix(index): normalize and concat paths via path.join()
1 parent 4c1ccaa commit 26e47ca

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed
 

‎src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export default function loader(content) {
3232
const relativePath = relativeUrl && `${path.dirname(relativeUrl)}/`;
3333
// eslint-disable-next-line no-bitwise
3434
if (~relativePath.indexOf('../')) {
35-
outputPath = path.posix.join(outputPath, relativePath, url);
35+
outputPath = path.join(outputPath, relativePath, url);
3636
} else {
37-
outputPath = relativePath + url;
37+
outputPath = path.join(relativePath, url);
3838
}
3939
}
4040

@@ -43,7 +43,7 @@ export default function loader(content) {
4343
if (options.publicPath !== undefined) {
4444
// support functions as publicPath to generate them dynamically
4545
publicPath = JSON.stringify(
46-
typeof options.publicPath === 'function' ? options.publicPath(url) : options.publicPath + url,
46+
typeof options.publicPath === 'function' ? options.publicPath(url) : path.join(options.publicPath || '', url),
4747
);
4848
} else {
4949
publicPath = `__webpack_public_path__ + ${JSON.stringify(outputPath)}`;

‎test/options/__snapshots__/outputPath.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Object {
7777
"assets": Array [
7878
"output_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
7979
],
80-
"source": "module.exports = \\"public_path9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
80+
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
8181
}
8282
`;
8383

‎test/options/__snapshots__/publicPath.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ Object {
2323
"assets": Array [
2424
"9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
2525
],
26-
"source": "module.exports = \\"public_path9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
26+
"source": "module.exports = \\"public_path/9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
2727
}
2828
`;

‎test/options/__snapshots__/useRelativePath.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Object {
3030
exports[`Options useRelativePath \`true\` with relative \`context\` 1`] = `
3131
Object {
3232
"assets": Array [
33-
"./9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
33+
"9c87cbf3ba33126ffd25ae7f2f6bbafb.png",
3434
],
35-
"source": "module.exports = __webpack_public_path__ + \\"./9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
35+
"source": "module.exports = __webpack_public_path__ + \\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";",
3636
}
3737
`;

0 commit comments

Comments
 (0)
This repository has been archived.