Skip to content

Commit

Permalink
fix($resource): prevent URL template from collapsing into an empty st…
Browse files Browse the repository at this point in the history
…ring

Closes angular#5455
  • Loading branch information
Gias Kay Lee committed Dec 20, 2013
1 parent df2b88e commit 84f1370
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ngResource/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+($|\?))/, '.');
Expand Down
7 changes: 7 additions & 0 deletions test/ngResource/resourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 84f1370

Please sign in to comment.