Skip to content

Commit 3c185c4

Browse files
authored
Merge pull request mgonto#1374 from ar45/honor_authority_without_schema_in_url
Honor authority without schema in url
2 parents 144c3da + 31b63e3 commit 3c185c4

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/restangular.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(function (root, factory) {
22
// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
33
if (typeof define === 'function' && define.amd) {
4-
define(['angular', 'lodash'], factory);
4+
define(['lodash', 'angular'], factory);
55
} else if (typeof module === 'object' && module.exports) {
6-
module.exports = factory(require('angular'), require('lodash'));
6+
module.exports = factory(require('lodash'), require('angular'));
77
} else {
88
// No global export, Restangular will register itself as Angular.js module
99
factory(root._, root.angular);
@@ -648,7 +648,7 @@ restangular.provider('Restangular', function() {
648648
Path.prototype = new BaseCreator();
649649

650650
Path.prototype.normalizeUrl = function (url){
651-
var parts = /(http[s]?:\/\/)?(.*)?/.exec(url);
651+
var parts = /((?:http[s]?:)?\/\/)?(.*)?/.exec(url);
652652
parts[2] = parts[2].replace(/[\\\/]+/g, '/');
653653
return (typeof parts[1] !== 'undefined')? parts[1] + parts[2] : parts[2];
654654
};

test/restangularSpec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,5 +1149,16 @@ describe("Restangular", function() {
11491149

11501150
$httpBackend.flush();
11511151
});
1152+
1153+
it("Should work with absolute URL with //authority", function() {
1154+
var newRes = Restangular.withConfig(function(RestangularConfigurer){
1155+
RestangularConfigurer.setBaseUrl('//localhost:8080');
1156+
});
1157+
expect(newRes.configuration.baseUrl).toEqual('//localhost:8080');
1158+
newRes.all("customers////").getList();
1159+
$httpBackend.expectGET('//localhost:8080/customers/').respond([]);
1160+
1161+
$httpBackend.flush();
1162+
});
11521163
});
11531164
});

0 commit comments

Comments
 (0)