Skip to content

Commit

Permalink
fix: decode incoming pathnames (#21)
Browse files Browse the repository at this point in the history
Issue: #20
  • Loading branch information
Seb35 authored and lukeed committed Apr 7, 2019
1 parent 0ca66b1 commit 54dde5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/sirv/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = function (dir, opts={}) {

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

return function (req, res, next) {
let pathname = req.path || req.pathname || parser(req).pathname;
let pathname = decodeURIComponent(req.path || req.pathname || parser(req).pathname);
let data = find(pathname, extensions);
if (!data) return next ? next() : notFound(res);

Expand Down

0 comments on commit 54dde5f

Please sign in to comment.