peertube-plugin-livechat/server/lib/prosody/config/domain.ts

19 lines
550 B
TypeScript
Raw Normal View History

2024-05-23 09:42:14 +00:00
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
//
// SPDX-License-Identifier: AGPL-3.0-only
import type { RegisterServerOptions } from '@peertube/peertube-types'
async function getProsodyDomain (options: RegisterServerOptions): Promise<string> {
const url = options.peertubeHelpers.config.getWebserverUrl()
const matches = url.match(/^https?:\/\/([^:/]*)(:\d+)?(\/|$)/)
if (!matches) {
throw new Error(`Cant get a domain name from url '${url}'`)
}
return matches[1]
}
export {
getProsodyDomain
}