File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ export function matchPattern(pattern, pathname) {
117
117
var remainingPathname , paramValues ;
118
118
if ( match != null ) {
119
119
paramValues = Array . prototype . slice . call ( match , 1 ) . map ( function ( v ) {
120
- return v != null ? decodeURIComponent ( v ) : v ;
120
+ return v != null ? decodeURIComponent ( v . replace ( / \+ / g , '%20' ) ) : v ;
121
121
} ) ;
122
122
123
123
if ( captureRemaining ) {
@@ -177,7 +177,7 @@ export function formatPattern(pattern, params) {
177
177
) ;
178
178
179
179
if ( paramValue != null )
180
- pathname += encodeURI ( paramValue ) ;
180
+ pathname += encodeURI ( paramValue ) . replace ( / % 2 0 / g , '+' ) ;
181
181
} else if ( token === '(' ) {
182
182
parenCount += 1 ;
183
183
} else if ( token === ')' ) {
@@ -193,7 +193,7 @@ export function formatPattern(pattern, params) {
193
193
) ;
194
194
195
195
if ( paramValue != null )
196
- pathname += encodeURIComponent ( paramValue ) ;
196
+ pathname += encodeURIComponent ( paramValue ) . replace ( / % 2 0 / g , '+' ) ;
197
197
} else {
198
198
pathname += token ;
199
199
}
Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ describe('formatPattern', function () {
245
245
246
246
describe ( 'and some params have special URL encoding' , function ( ) {
247
247
it ( 'returns the correct path' , function ( ) {
248
- expect ( formatPattern ( pattern , { id : 'one, two' } ) ) . toEqual ( 'comments/one%2C%20two /edit' ) ;
248
+ expect ( formatPattern ( pattern , { id : 'one, two' } ) ) . toEqual ( 'comments/one%2C+two /edit' ) ;
249
249
} ) ;
250
250
} ) ;
251
251
You can’t perform that action at this time.
0 commit comments