File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -279,12 +279,17 @@ angular.module('ngResource', ['ng']).
279
279
url : function ( params ) {
280
280
var self = this ,
281
281
url = this . template ,
282
+ val ,
282
283
encodedVal ;
283
284
284
285
params = params || { } ;
285
286
forEach ( this . urlParams , function ( _ , urlParam ) {
286
- encodedVal = encodeUriSegment ( params [ urlParam ] || self . defaults [ urlParam ] || "" ) ;
287
- url = url . replace ( new RegExp ( ":" + urlParam + "(\\W)" , "g" ) , encodedVal + "$1" ) ;
287
+ if ( val = ( params [ urlParam ] || self . defaults [ urlParam ] ) ) {
288
+ encodedVal = encodeUriSegment ( val ) ;
289
+ url = url . replace ( new RegExp ( ":" + urlParam + "(\\W)" , "g" ) , encodedVal + "$1" ) ;
290
+ } else {
291
+ url = url . replace ( new RegExp ( "/?:" + urlParam + "(\\W)" , "g" ) , '$1' ) ;
292
+ }
288
293
} ) ;
289
294
url = url . replace ( / \/ ? # $ / , '' ) ;
290
295
var query = [ ] ;
Original file line number Diff line number Diff line change @@ -48,12 +48,14 @@ describe("resource", function() {
48
48
$httpBackend . expect ( 'GET' , '/Path' ) ;
49
49
$httpBackend . expect ( 'GET' , '/Path/1' ) ;
50
50
$httpBackend . expect ( 'GET' , '/Path/2/3' ) ;
51
- $httpBackend . expect ( 'GET' , '/Path/4/5/6' ) ;
51
+ $httpBackend . expect ( 'GET' , '/Path/4/5' ) ;
52
+ $httpBackend . expect ( 'GET' , '/Path/6/7/8' ) ;
52
53
53
54
R . get ( { } ) ;
54
55
R . get ( { a :1 } ) ;
55
56
R . get ( { a :2 , b :3 } ) ;
56
- R . get ( { a :4 , b :5 , c :6 } ) ;
57
+ R . get ( { a :4 , c :5 } ) ;
58
+ R . get ( { a :6 , b :7 , c :8 } ) ;
57
59
} ) ;
58
60
59
61
You can’t perform that action at this time.
0 commit comments