diff options
| -rw-r--r-- | src/ngResource/resource.js | 2 | ||||
| -rw-r--r-- | test/ngResource/resourceSpec.js | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index dedbf860..8874bbec 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -401,7 +401,7 @@ angular.module('ngResource', ['ng']). }); // strip trailing slashes and set the url - url = url.replace(/\/+$/, ''); + url = url.replace(/\/+$/, '') || '/'; // then replace collapse `/.` if found in the last URL path segment before the query // E.g. `http://url.com/id./format?q=x` becomes `http://url.com/id.format?q=x` url = url.replace(/\/\.(?=\w+($|\?))/, '.'); diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index 28154313..b23f0ca4 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -150,6 +150,13 @@ describe("resource", function() { R.get({a:6, b:7, c:8}); }); + it('should not collapsed the url into an empty string', function() { + var R = $resource('/:foo/:bar/'); + + $httpBackend.when('GET', '/').respond('{}'); + + R.get({}); + }); it('should support escaping colons in url template', function() { var R = $resource('http://localhost\\:8080/Path/:a/\\:stillPath/:b'); |
