mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 06:34:39 -04:00
Refactor existing code to add the configured domain to connect-src
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
98b0bf25d2
commit
d7986b1920
4 changed files with 29 additions and 20 deletions
19
lib/config/buildDomainOriginWithProtocol.js
Normal file
19
lib/config/buildDomainOriginWithProtocol.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue