Skip to content

Commit

Permalink
fix conflict accident per #75 and <11306e1>
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Apr 28, 2020
1 parent 5660b68 commit 6131069
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/layer.js
@@ -1,6 +1,6 @@
const debug = require('debug')('koa-router');
const { pathToRegexp, compile, parse } = require('path-to-regexp');
const uri = require('urijs');
const { parse: parseUrl, format: formatUrl } = require('url');

module.exports = Layer;

Expand Down Expand Up @@ -145,9 +145,14 @@ Layer.prototype.url = function (params, options) {
replaced = toPath(replace);

if (options && options.query) {
replaced = new uri(replaced)
replaced.search(options.query);
return replaced.toString();
replaced = parseUrl(replaced);
if (typeof options.query === 'string') {
replaced.search = options.query;
} else {
replaced.search = undefined;
replaced.query = options.query;
}
return formatUrl(replaced);
}

return replaced;
Expand Down

2 comments on commit 6131069

@avindra
Copy link

@avindra avindra commented on 6131069 Jul 6, 2020

Choose a reason for hiding this comment

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

Original author @panva

@niftylettuce
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please sign in to comment.