mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix($resource): prevent URL template from collapsing into an empty string
if url template would result in an empty string, we should make a request to '/' instead. Closes #5455 Closes #5493
This commit is contained in:
parent
01c5be4681
commit
131e4014b8
2 changed files with 8 additions and 1 deletions
|
|
@ -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+($|\?))/, '.');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue