diff options
| -rw-r--r-- | src/ngResource/resource.js | 2 | ||||
| -rw-r--r-- | test/ngResource/resourceSpec.js | 12 | 
2 files changed, 13 insertions, 1 deletions
diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 81b57f43..484e9b01 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -308,7 +308,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("(^|[^\\\\]):" + param + "\\W").test(template))) {            urlParams[param] = true;          }        }); diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index d0bcbefc..1edb5a95 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -129,6 +129,18 @@ 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(':relativePath'); +    $httpBackend.expect('GET', 'data.json').respond('{}'); +    R.get({ relativePath: 'data.json' }); +  }); + +  it('should handle + in url params', function () { +    var R = $resource('/api/myapp/:myresource?from=:from&to=:to&histlen=:histlen'); +    $httpBackend.expect('GET', '/api/myapp/pear+apple?from=2012-04-01&to=2012-04-29&histlen=3').respond('{}'); +    R.get({ myresource: 'pear+apple', from : '2012-04-01', to : '2012-04-29', histlen : 3  }); +  }); +    it('should encode & in url params', function() {      var R = $resource('/Path/:a');  | 
