2024-05-23 11:42:14 +02:00
|
|
|
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-01-11 01:29:33 +01:00
|
|
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
|
|
|
|
2021-05-06 13:31:55 +02:00
|
|
|
async function getProsodyDomain (options: RegisterServerOptions): Promise<string> {
|
2021-05-06 21:00:42 +02:00
|
|
|
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]
|
2021-05-06 13:31:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
getProsodyDomain
|
|
|
|
}
|