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 +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -590,11 +590,12 @@ angular.module('ngResource', ['ng']).
590
590
url = url . replace ( / \/ + $ / , '' ) || '/' ;
591
591
}
592
592
593
- // then replace collapse `/.` if found in the last URL path segment before the query
594
- // E.g. `http://url.com/id./ format?q=x` becomes `http://url.com/id.format?q=x`
593
+ // Collapse `/.` if found in the last URL path segment before the query.
594
+ // E.g. `http://url.com/id/. format?q=x` becomes `http://url.com/id.format?q=x`.
595
595
url = url . replace ( / \/ \. (? = \w + ( $ | \? ) ) / , '.' ) ;
596
- // replace escaped `/\.` with `/.`
597
- config . url = protocolAndIpv6 + url . replace ( / \/ \\ \. / , '/.' ) ;
596
+ // Replace escaped `/\.` with `/.`.
597
+ // (If `\.` comes from a param value, it will be encoded as `%5C.`.)
598
+ config . url = protocolAndIpv6 + url . replace ( / \/ ( \\ | % 5 C ) \. / , '/.' ) ;
598
599
599
600
600
601
// set params - delegate param encoding to $http
Original file line number Diff line number Diff line change @@ -1456,6 +1456,18 @@ describe('basic usage', function() {
1456
1456
$httpBackend . expect ( 'POST' , '/users/.json' ) . respond ( ) ;
1457
1457
$resource ( '/users/\\.json' ) . save ( { } ) ;
1458
1458
} ) ;
1459
+ it ( 'should work with save() if dynamic params' , function ( ) {
1460
+ $httpBackend . expect ( 'POST' , '/users/.json' ) . respond ( ) ;
1461
+ $resource ( '/users/:json' , { json : '\\.json' } ) . save ( { } ) ;
1462
+ } ) ;
1463
+ it ( 'should work with query() if dynamic params' , function ( ) {
1464
+ $httpBackend . expect ( 'GET' , '/users/.json' ) . respond ( ) ;
1465
+ $resource ( '/users/:json' , { json : '\\.json' } ) . query ( ) ;
1466
+ } ) ;
1467
+ it ( 'should work with get() if dynamic params' , function ( ) {
1468
+ $httpBackend . expect ( 'GET' , '/users/.json' ) . respond ( ) ;
1469
+ $resource ( '/users/:json' , { json : '\\.json' } ) . get ( ) ;
1470
+ } ) ;
1459
1471
} ) ;
1460
1472
} ) ;
1461
1473
You can’t perform that action at this time.
0 commit comments