File tree 2 files changed +26
-4
lines changed
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 30
30
* and you are ready to get started!
31
31
*
32
32
* @param {string } url A parametrized URL template with parameters prefixed by `:` as in
33
- * `/user/:username`. If you are using a URL with a port number (e.g.
34
- * `http://example.com:8080/api`), you'll need to escape the colon character before the port
35
- * number, like this: `$resource('http://example.com\\:8080/api')`.
33
+ * `/user/:username`.
36
34
*
37
35
* If you are using a url with a suffix, just add the suffix, like this:
38
36
* `$resource('http://example.com/resource.json')` or `$resource('http://example.com/:id.json')
@@ -346,7 +344,9 @@ angular.module('ngResource', ['ng']).
346
344
var urlParams = self . urlParams = { } ;
347
345
forEach ( url . split ( / \W / ) , function ( param ) {
348
346
if ( param && ( new RegExp ( "(^|[^\\\\]):" + param + "(\\W|$)" ) . test ( url ) ) ) {
349
- urlParams [ param ] = true ;
347
+ if ( new RegExp ( "^[^0-9].*$" ) . test ( param ) ) {
348
+ urlParams [ param ] = true ;
349
+ }
350
350
}
351
351
} ) ;
352
352
url = url . replace ( / \\ : / g, ':' ) ;
Original file line number Diff line number Diff line change @@ -73,6 +73,28 @@ describe("resource", function() {
73
73
R . get ( { a :6 , b :7 , c :8 } ) ;
74
74
} ) ;
75
75
76
+ it ( 'should ignore parameters starting with digit' , function ( ) {
77
+ var R = $resource ( 'http://www.example.com:8080/Path/:4a/:a' ) ;
78
+
79
+ $httpBackend . when ( 'GET' , 'http://www.example.com:8080/Path/:4a' ) . respond ( '{}' ) ;
80
+ $httpBackend . when ( 'GET' , 'http://www.example.com:8080/Path/:4a/0' ) . respond ( '{}' ) ;
81
+ $httpBackend . when ( 'GET' , 'http://www.example.com:8080/Path/:4a?8080=1' ) . respond ( '{}' ) ;
82
+
83
+ R . get ( { } ) ;
84
+ R . get ( { a :0 } ) ;
85
+ R . get ( { "8080" :1 } ) ;
86
+ } ) ;
87
+
88
+ it ( 'should not ignore parameters that contain digits but do not start with digit' , function ( ) {
89
+ var R = $resource ( '/Path/:a42' ) ;
90
+
91
+ $httpBackend . when ( 'GET' , '/Path' ) . respond ( '{}' ) ;
92
+ $httpBackend . when ( 'GET' , '/Path/7' ) . respond ( '{}' ) ;
93
+
94
+ R . get ( { } ) ;
95
+ R . get ( { a42 : 7 } ) ;
96
+ } ) ;
97
+
76
98
it ( 'should not ignore leading slashes of undefinend parameters that have non-slash trailing sequence' , function ( ) {
77
99
var R = $resource ( '/Path/:a.foo/:b.bar/:c.baz' ) ;
78
100
You can’t perform that action at this time.
0 commit comments