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 c1c9ea6 commit 4073161
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 @@ -869,13 +869,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 4073161

Please sign in to comment.