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
|
|
|
|
|
2023-12-27 11:48:45 +00:00
|
|
|
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
|
|
|
|
2024-09-09 16:47:21 +00:00
|
|
|
function getBaseRoute ({ peertubeHelpers }: RegisterClientOptions, permanent = false): string {
|
2023-12-27 11:48:45 +00:00
|
|
|
if (permanent) {
|
|
|
|
return '/plugins/livechat/router'
|
|
|
|
}
|
|
|
|
// NB: this will come with Peertube > 3.2.1 (3.3.0?)
|
|
|
|
if (peertubeHelpers.getBaseRouterRoute) {
|
|
|
|
return peertubeHelpers.getBaseRouterRoute()
|
|
|
|
}
|
|
|
|
// We are guessing the route with the correct plugin version with this trick:
|
|
|
|
const staticBase = peertubeHelpers.getBaseStaticRoute()
|
|
|
|
return staticBase.replace(/\/static.*$/, '/router')
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
getBaseRoute
|
|
|
|
}
|