This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
-
4
-
5
3
function Route ( template , defaults ) {
6
4
this . template = template = template + '#' ;
7
5
this . defaults = defaults || { } ;
8
6
var urlParams = this . urlParams = { } ;
9
7
forEach ( template . split ( / \W / ) , function ( param ) {
10
- if ( param && template . match ( new RegExp ( ":" + param + "\\W" ) ) ) {
8
+ if ( param && template . match ( new RegExp ( "[^\\\\] :" + param + "\\W" ) ) ) {
11
9
urlParams [ param ] = true ;
12
10
}
13
11
} ) ;
12
+ this . template = template . replace ( / \\ : / g, ':' ) ;
14
13
}
15
14
16
15
Route . prototype = {
Original file line number Diff line number Diff line change @@ -52,6 +52,13 @@ describe("resource", function() {
52
52
R . get ( { a :4 , b :5 , c :6 } ) ;
53
53
} ) ) ;
54
54
55
+ it ( 'should support escaping collons in url template' , inject ( function ( $httpBackend ) {
56
+ var R = resource . route ( 'http://localhost\\:8080/Path/:a/\\:stillPath/:b' ) ;
57
+
58
+ $httpBackend . expect ( 'GET' , 'http://localhost:8080/Path/foo/:stillPath/bar' ) . respond ( ) ;
59
+ R . get ( { a : 'foo' , b : 'bar' } ) ;
60
+ } ) ) ;
61
+
55
62
it ( 'should correctly encode url params' , inject ( function ( $httpBackend ) {
56
63
var R = resource . route ( '/Path/:a' ) ;
57
64
You can’t perform that action at this time.
0 commit comments