Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #10407 from brave/fix/getOrigin
Browse files Browse the repository at this point in the history
Fix getOrigin to work with muon.url.parse
  • Loading branch information
bbondy authored and diracdeltas committed Aug 10, 2017
1 parent 263b6d5 commit 794b2ed
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions js/state/siteUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,13 +855,18 @@ module.exports.getOrigin = function (location) {
if (typeof location !== 'string') {
return null
}

if (location.startsWith('file://')) {
return 'file:///'
}

let parsed = urlParse(location)
if (parsed.origin) {
// parsed.origin is specific to muon.url.parse
return parsed.origin.replace(/\/+$/, '')
}
if (parsed.host && parsed.protocol) {
return parsed.slashes ? [parsed.protocol, parsed.host].join('//') : [parsed.protocol, parsed.host].join('')
} else {
return null
}
return null
}

0 comments on commit 794b2ed

Please sign in to comment.