Skip to content

Commit 54dde5f

Browse files
Seb35lukeed
authored andcommittedApr 7, 2019
fix: decode incoming pathnames (#21)
Issue: #20
1 parent 0ca66b1 commit 54dde5f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎packages/sirv/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = function (dir, opts={}) {
4747

4848
if (opts.dev) {
4949
return function (req, res, next) {
50-
let uri = req.path || req.pathname || parser(req).pathname;
50+
let uri = decodeURIComponent(req.path || req.pathname || parser(req).pathname);
5151
let arr = uri.includes('.') ? [uri] : toAssume(uri, extensions);
5252
let file = arr.map(x => join(dir, x)).find(fs.existsSync);
5353
if (!file) return next ? next() : notFound(res);
@@ -76,7 +76,7 @@ module.exports = function (dir, opts={}) {
7676
});
7777

7878
return function (req, res, next) {
79-
let pathname = req.path || req.pathname || parser(req).pathname;
79+
let pathname = decodeURIComponent(req.path || req.pathname || parser(req).pathname);
8080
let data = find(pathname, extensions);
8181
if (!data) return next ? next() : notFound(res);
8282

0 commit comments

Comments
 (0)
Please sign in to comment.