mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix($resource): Route constructor, updated RegExp
Update RegExp to allow urlParams with out leading slash (/).
- Will allow reoucese to be loaded from a relative path
Example:
var R = $resource(':path');
R.get({ path : 'data.json' });
Example usage:
Load resources in applications not using webserver, ie local webapp in on a tablet.
This commit is contained in:
parent
2f437e8978
commit
06ed8ef012
2 changed files with 7 additions and 1 deletions
|
|
@ -290,7 +290,7 @@ angular.module('ngResource', ['ng']).
|
|||
this.defaults = defaults || {};
|
||||
var urlParams = this.urlParams = {};
|
||||
forEach(template.split(/\W/), function(param){
|
||||
if (param && template.match(new RegExp("[^\\\\]:" + param + "\\W"))) {
|
||||
if (param && (new RegExp("((\\w|\\/|^)(?!\\\\:" + param + ")):" + param + "\\W")).test(template)) {
|
||||
urlParams[param] = true;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -129,6 +129,12 @@ describe("resource", function() {
|
|||
R.get({a: 'doh@fo o', ':bar': '$baz@1', '!do&h': 'g=a h'});
|
||||
});
|
||||
|
||||
it('should allow relative paths in resource url', function () {
|
||||
var R = $resource(':a');
|
||||
$httpBackend.expect('GET', 'data.json').respond('{}');
|
||||
R.get({ a: 'data.json' });
|
||||
});
|
||||
|
||||
|
||||
it('should encode & in url params', function() {
|
||||
var R = $resource('/Path/:a');
|
||||
|
|
|
|||
Loading…
Reference in a new issue