Skip to content

Commit

Permalink
Replace with window.location
Browse files Browse the repository at this point in the history
  • Loading branch information
kravets-levko committed Feb 16, 2018
1 parent 21b753f commit d2c5be5
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions client/app/services/utils.js
@@ -1,18 +1,14 @@
function fullUrl($location, url) {
const scheme = $location.protocol().toLowerCase();
const defaultPort = scheme === 'https' ? 443 : 80;
const host = $location.host();
const port = parseInt($location.port(), 10);
function fullUrl(url) {
const location = window.location;

let result = scheme + '://' + host;
if (port !== defaultPort) {
result = result + ':' + port;
}
return result + url;
const scheme = location.protocol.toLowerCase();
const host = location.host;

return scheme + '//' + host + url;
}

export default function init(ngModule) {
ngModule.factory('Utils', $location => ({
fullUrl: url => fullUrl($location, url),
ngModule.factory('Utils', () => ({
fullUrl,
}));
}

0 comments on commit d2c5be5

Please sign in to comment.