Skip to content

Commit

Permalink
Merge pull request #1374 from ar45/honor_authority_without_schema_in_url
Browse files Browse the repository at this point in the history
Honor authority without schema in url
  • Loading branch information
daviesgeek authored Jun 17, 2016
2 parents 144c3da + 31b63e3 commit 3c185c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/restangular.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function (root, factory) {
// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
if (typeof define === 'function' && define.amd) {
define(['angular', 'lodash'], factory);
define(['lodash', 'angular'], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require('angular'), require('lodash'));
module.exports = factory(require('lodash'), require('angular'));
} else {
// No global export, Restangular will register itself as Angular.js module
factory(root._, root.angular);
Expand Down Expand Up @@ -648,7 +648,7 @@ restangular.provider('Restangular', function() {
Path.prototype = new BaseCreator();

Path.prototype.normalizeUrl = function (url){
var parts = /(http[s]?:\/\/)?(.*)?/.exec(url);
var parts = /((?:http[s]?:)?\/\/)?(.*)?/.exec(url);
parts[2] = parts[2].replace(/[\\\/]+/g, '/');
return (typeof parts[1] !== 'undefined')? parts[1] + parts[2] : parts[2];
};
Expand Down
11 changes: 11 additions & 0 deletions test/restangularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1149,5 +1149,16 @@ describe("Restangular", function() {

$httpBackend.flush();
});

it("Should work with absolute URL with //authority", function() {
var newRes = Restangular.withConfig(function(RestangularConfigurer){
RestangularConfigurer.setBaseUrl('//localhost:8080');
});
expect(newRes.configuration.baseUrl).toEqual('//localhost:8080');
newRes.all("customers////").getList();
$httpBackend.expectGET('//localhost:8080/customers/').respond([]);

$httpBackend.flush();
});
});
});

0 comments on commit 3c185c4

Please sign in to comment.