Skip to content

Commit bd6a593

Browse files
Dima PaloskinSpaceK33z
authored andcommitted
use decodeURIComponent for getFilenameFromUrl final output (#173)
1 parent 8e870fd commit bd6a593

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/GetFilenameFromUrl.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ var urlParse = require("url").parse;
33

44
function getFilenameFromUrl(publicPath, outputPath, url) {
55
var filename;
6-
url = decodeURIComponent(url);
76

87
// localPrefix is the folder our bundle should be in
98
var localPrefix = urlParse(publicPath || "/", false, true);
@@ -30,7 +29,7 @@ function getFilenameFromUrl(publicPath, outputPath, url) {
3029
return false;
3130
}
3231
// and if not match, use outputPath as filename
33-
return filename ? pathJoin(outputPath, filename) : outputPath;
32+
return decodeURIComponent(filename ? pathJoin(outputPath, filename) : outputPath);
3433

3534
}
3635

test/GetFilenameFromUrl.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ describe("GetFilenameFromUrl", function() {
8989
outputPath: "/",
9090
publicPath: "//test.domain/protocol/relative/",
9191
expected: "/sample.js"
92-
}
92+
}, {
93+
url: "/pathname%20with%20spaces.js",
94+
outputPath: "/",
95+
publicPath: "/",
96+
expected: "/pathname with spaces.js"
97+
},
9398
];
9499
results.forEach(testUrl);
95100
});

0 commit comments

Comments
 (0)