File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,14 +2,6 @@ var invariant = require('react/lib/invariant');
22var merge = require ( 'qs/lib/utils' ) . merge ;
33var qs = require ( 'qs' ) ;
44
5- function decodePathSegment ( string ) {
6- return decodeURIComponent ( string . replace ( / \+ / g, ' ' ) ) ;
7- }
8-
9- function encodePathSegment ( string ) {
10- return encodeURIComponent ( string ) . replace ( / % 2 0 / g, '+' ) ;
11- }
12-
135var paramCompileMatcher = / : ( [ a - z A - Z _ $ ] [ a - z A - Z 0 - 9 _ $ ] * ) | [ * . ( ) \[ \] \\ + | { } ^ $ ] / g;
146var paramInjectMatcher = / : ( [ a - z A - Z _ $ ] [ a - z A - Z 0 - 9 _ $ ? ] * [ ? ] ? ) | [ * ] / g;
157var paramInjectTrailingSlashMatcher = / \/ \/ \? | \/ \? / g;
@@ -46,15 +38,15 @@ var Path = {
4638 /**
4739 * Safely decodes special characters in the given URL path.
4840 */
49- decode : function decodePath ( path ) {
50- return String ( path ) . split ( '/' ) . map ( decodePathSegment ) . join ( '/' ) ;
41+ decode : function ( path ) {
42+ return decodeURI ( path . replace ( / \+ / g , ' ' ) ) ;
5143 } ,
5244
5345 /**
5446 * Safely encodes special characters in the given URL path.
5547 */
56- encode : function encodePath ( path ) {
57- return String ( path ) . split ( '/' ) . map ( encodePathSegment ) . join ( '/ ') ;
48+ encode : function ( path ) {
49+ return encodeURI ( path ) . replace ( / % 2 0 / g , '+ ') ;
5850 } ,
5951
6052 /**
Original file line number Diff line number Diff line change 11var expect = require ( 'expect' ) ;
22var Path = require ( '../Path' ) ;
33
4+ describe ( 'Path.decode' , function ( ) {
5+ it ( 'properly decodes a path with a query string' , function ( ) {
6+ expect ( Path . decode ( '/my/short+path?a=b&c=d' ) ) . toEqual ( '/my/short path?a=b&c=d' ) ;
7+ } ) ;
8+ } ) ;
9+
10+ describe ( 'Path.encode' , function ( ) {
11+ it ( 'properly encodes a path with a query string' , function ( ) {
12+ expect ( Path . encode ( '/my/short path?a=b&c=d' ) ) . toEqual ( '/my/short+path?a=b&c=d' ) ;
13+ } ) ;
14+ } ) ;
15+
416describe ( 'Path.extractParamNames' , function ( ) {
517 describe ( 'when a pattern contains no dynamic segments' , function ( ) {
618 it ( 'returns an empty array' , function ( ) {
You can’t perform that action at this time.
0 commit comments