File tree Expand file tree Collapse file tree 4 files changed +26
-27
lines changed Expand file tree Collapse file tree 4 files changed +26
-27
lines changed Original file line number Diff line number Diff line change 1
1
var invariant = require ( 'react/lib/invariant' ) ;
2
2
var merge = require ( 'react/lib/merge' ) ;
3
3
var qs = require ( 'querystring' ) ;
4
- var urlDecode = require ( './urlDecode' ) ;
5
- var urlEncode = require ( './urlEncode' ) ;
4
+ var URL = require ( './URL' ) ;
6
5
7
6
var paramMatcher = / ( (?: : [ a - z _ $ ] [ a - z 0 - 9 _ $ ] * ) | \* ) / ig;
8
7
var queryMatcher = / \? ( .+ ) / ;
@@ -43,14 +42,14 @@ var Path = {
43
42
*/
44
43
extractParams : function ( pattern , path ) {
45
44
if ( ! isDynamicPattern ( pattern ) ) {
46
- if ( pattern === urlDecode ( path ) )
45
+ if ( pattern === URL . decode ( path ) )
47
46
return { } ; // No dynamic segments, but the paths match.
48
47
49
48
return null ;
50
49
}
51
50
52
51
var compiled = compilePattern ( pattern ) ;
53
- var match = urlDecode ( path ) . match ( compiled . matcher ) ;
52
+ var match = URL . decode ( path ) . match ( compiled . matcher ) ;
54
53
55
54
if ( ! match )
56
55
return null ;
@@ -89,7 +88,7 @@ var Path = {
89
88
'Missing "' + paramName + '" parameter for path "' + pattern + '"'
90
89
) ;
91
90
92
- return urlEncode ( params [ paramName ] ) ;
91
+ return URL . encode ( params [ paramName ] ) ;
93
92
} ) ;
94
93
} ,
95
94
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