Skip to content

Commit

Permalink
fix: always set req.originalUrl value
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Feb 16, 2018
1 parent 73392ea commit bb9e366
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/polka/index.js
Expand Up @@ -13,7 +13,6 @@ function value(x) {
}

function mutate(str, req) {
req.originalUrl = req.originalUrl || req.url;
req.url = req.url.substring(str.length) || '/';
req.pathname = req.pathname.substring(str.length) || '/';
}
Expand Down Expand Up @@ -67,6 +66,7 @@ class Polka extends Router {
handler(req, res, info) {
info = info || this.parse(req);
let fn, arr=this.wares, obj=this.find(req.method, info.pathname);
req.originalUrl = req.originalUrl || req.url;
req.pathname = info.pathname;
if (obj) {
fn = obj.handler;
Expand Down

3 comments on commit bb9e366

@ramlmn
Copy link

@ramlmn ramlmn commented on bb9e366 Feb 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, wanted to do that last night, waited for few testing and you've added it anyway.

@lukeed
Copy link
Owner Author

@lukeed lukeed commented on bb9e366 Feb 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha yup, figured there was no reason not to have it always. Plus Express has it too

@ramlmn
Copy link

@ramlmn ramlmn commented on bb9e366 Feb 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its quite useful for global middlewares like serve-static. Trying to fix bugs in serv 😜 currently so found it useful.

Please sign in to comment.