File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var invariant = require ( 'react/lib/invariant' ) ;
22var merge = require ( 'react/lib/merge' ) ;
33var qs = require ( 'querystring' ) ;
4- var urlDecode = require ( './urlDecode' ) ;
5- var urlEncode = require ( './urlEncode' ) ;
4+ var URL = require ( './URL' ) ;
65
76var paramMatcher = / ( (?: : [ a - z _ $ ] [ a - z 0 - 9 _ $ ] * ) | \* ) / ig;
87var queryMatcher = / \? ( .+ ) / ;
@@ -43,14 +42,14 @@ var Path = {
4342 */
4443 extractParams : function ( pattern , path ) {
4544 if ( ! isDynamicPattern ( pattern ) ) {
46- if ( pattern === urlDecode ( path ) )
45+ if ( pattern === URL . decode ( path ) )
4746 return { } ; // No dynamic segments, but the paths match.
4847
4948 return null ;
5049 }
5150
5251 var compiled = compilePattern ( pattern ) ;
53- var match = urlDecode ( path ) . match ( compiled . matcher ) ;
52+ var match = URL . decode ( path ) . match ( compiled . matcher ) ;
5453
5554 if ( ! match )
5655 return null ;
@@ -89,7 +88,7 @@ var Path = {
8988 'Missing "' + paramName + '" parameter for path "' + pattern + '"'
9089 ) ;
9190
92- return urlEncode ( params [ paramName ] ) ;
91+ return URL . encode ( params [ paramName ] ) ;
9392 } ) ;
9493 } ,
9594
Original file line number Diff line number Diff line change 1+ var urlEncodedSpaceRE = / \+ / g;
2+ var encodedSpaceRE = / % 2 0 / g;
3+
4+ var URL = {
5+
6+ /* These functions were copied from the https://github.com/cujojs/rest source, MIT licensed */
7+
8+ decode : function ( str ) {
9+ // spec says space should be encoded as '+'
10+ str = str . replace ( urlEncodedSpaceRE , ' ' ) ;
11+ return decodeURIComponent ( str ) ;
12+ } ,
13+
14+ encode : function ( str ) {
15+ str = encodeURIComponent ( str ) ;
16+ // spec says space should be encoded as '+'
17+ return str . replace ( encodedSpaceRE , '+' ) ;
18+ }
19+
20+ } ;
21+
22+ module . exports = URL ;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments