mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 09:46:30 -05:00
20 lines
585 B
JavaScript
20 lines
585 B
JavaScript
|
module.exports = {
|
||
|
buildDomainOriginWithProtocol: function (config, baseProtocol) {
|
||
|
const isStandardHTTPsPort = config.protocolUseSSL && config.port === 443
|
||
|
const isStandardHTTPPort = !config.protocolUseSSL && config.port === 80
|
||
|
|
||
|
if (!config.domain) {
|
||
|
return ''
|
||
|
}
|
||
|
let origin = ''
|
||
|
const protocol = baseProtocol + (config.protocolUseSSL ? 's' : '') + '://'
|
||
|
origin = protocol + config.domain
|
||
|
if (config.urlAddPort) {
|
||
|
if (!isStandardHTTPPort || !isStandardHTTPsPort) {
|
||
|
origin += ':' + config.port
|
||
|
}
|
||
|
}
|
||
|
return origin
|
||
|
}
|
||
|
}
|