diff --git a/lib/layer.js b/lib/layer.js index bb09bb9..7cddcbe 100644 --- a/lib/layer.js +++ b/lib/layer.js @@ -119,7 +119,7 @@ Layer.prototype.url = function (params, options) { } } - const toPath = compile(url, Object.assign({ encode: encodeURIComponent }, options)); + const toPath = compile(url, { encode: encodeURIComponent, ...options }); let replaced; const tokens = parse(url); diff --git a/test/lib/layer.js b/test/lib/layer.js index 31c26a1..9b82847 100644 --- a/test/lib/layer.js +++ b/test/lib/layer.js @@ -303,9 +303,14 @@ describe('Layer', function () { url.should.equal('/programming/how-to-node'); }); - it('escapes using encodeURIComponent()', function() { - const route = new Layer('/:category/:title', ['get'], [function () {}], {name: 'books'}); - const url = route.url({ category: 'programming', title: 'how to node & js/ts' }); + it('escapes using encodeURIComponent()', function () { + const route = new Layer('/:category/:title', ['get'], [function () {}], { + name: 'books' + }); + const url = route.url({ + category: 'programming', + title: 'how to node & js/ts' + }); url.should.equal('/programming/how%20to%20node%20%26%20js%2Fts'); }); diff --git a/test/lib/router.js b/test/lib/router.js index 70a0993..67da1e1 100644 --- a/test/lib/router.js +++ b/test/lib/router.js @@ -1675,11 +1675,11 @@ describe('Router', function () { router.url(Symbol('books')).should.be.Error(); }); - it('escapes using encodeURIComponent()', function() { - const url = Router.url( - '/:category/:title', - { category: 'programming', title: 'how to node & js/ts' } - ); + it('escapes using encodeURIComponent()', function () { + const url = Router.url('/:category/:title', { + category: 'programming', + title: 'how to node & js/ts' + }); url.should.equal('/programming/how%20to%20node%20%26%20js%2Fts'); }); });