This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3-
4-
53function Route ( template , defaults ) {
64 this . template = template = template + '#' ;
75 this . defaults = defaults || { } ;
86 var urlParams = this . urlParams = { } ;
97 forEach ( template . split ( / \W / ) , function ( param ) {
10- if ( param && template . match ( new RegExp ( ":" + param + "\\W" ) ) ) {
8+ if ( param && template . match ( new RegExp ( "[^\\\\] :" + param + "\\W" ) ) ) {
119 urlParams [ param ] = true ;
1210 }
1311 } ) ;
12+ this . template = template . replace ( / \\ : / g, ':' ) ;
1413}
1514
1615Route . prototype = {
Original file line number Diff line number Diff line change @@ -52,6 +52,13 @@ describe("resource", function() {
5252 R . get ( { a :4 , b :5 , c :6 } ) ;
5353 } ) ) ;
5454
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+
5562 it ( 'should correctly encode url params' , inject ( function ( $httpBackend ) {
5663 var R = resource . route ( '/Path/:a' ) ;
5764
You can’t perform that action at this time.
0 commit comments