mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-22 01:10:23 +00:00
fix($resource): support escaping of ':' in resource url
So one can how define cors/jsonp resources with port number as:
resource.route('http://localhost\\:8080/Path')
This commit is contained in:
parent
a4fe51da3b
commit
6d6f875345
2 changed files with 9 additions and 3 deletions
|
|
@ -1,16 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
|
||||
function Route(template, defaults) {
|
||||
this.template = template = template + '#';
|
||||
this.defaults = defaults || {};
|
||||
var urlParams = this.urlParams = {};
|
||||
forEach(template.split(/\W/), function(param){
|
||||
if (param && template.match(new RegExp(":" + param + "\\W"))) {
|
||||
if (param && template.match(new RegExp("[^\\\\]:" + param + "\\W"))) {
|
||||
urlParams[param] = true;
|
||||
}
|
||||
});
|
||||
this.template = template.replace(/\\:/g, ':');
|
||||
}
|
||||
|
||||
Route.prototype = {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,13 @@ describe("resource", function() {
|
|||
R.get({a:4, b:5, c:6});
|
||||
}));
|
||||
|
||||
it('should support escaping collons in url template', inject(function($httpBackend) {
|
||||
var R = resource.route('http://localhost\\:8080/Path/:a/\\:stillPath/:b');
|
||||
|
||||
$httpBackend.expect('GET', 'http://localhost:8080/Path/foo/:stillPath/bar').respond();
|
||||
R.get({a: 'foo', b: 'bar'});
|
||||
}));
|
||||
|
||||
it('should correctly encode url params', inject(function($httpBackend) {
|
||||
var R = resource.route('/Path/:a');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue