forked from getredash/redash
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21b753f
commit d2c5be5
Showing
1 changed file
with
8 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
})); | ||
} |