diff --git a/meet-ce/backend/src/helpers/room.helper.ts b/meet-ce/backend/src/helpers/room.helper.ts index 34bed464..ad957107 100644 --- a/meet-ce/backend/src/helpers/room.helper.ts +++ b/meet-ce/backend/src/helpers/room.helper.ts @@ -10,7 +10,7 @@ import { } from '@openvidu-meet/typings'; import { INTERNAL_CONFIG } from '../config/internal-config.js'; import { MEET_ENV } from '../environment.js'; -import { getBasePath } from '../utils/html-injection.utils.js'; +import { getBasePath } from '../utils/html-dynamic-base-path.utils.js'; export class MeetRoomHelper { private constructor() { diff --git a/meet-ce/backend/src/repositories/room.repository.ts b/meet-ce/backend/src/repositories/room.repository.ts index 9cc2e72f..60c00d7b 100644 --- a/meet-ce/backend/src/repositories/room.repository.ts +++ b/meet-ce/backend/src/repositories/room.repository.ts @@ -257,27 +257,14 @@ export class RoomRepository extends BaseRepos * @returns The path portion of the URL without the basePath prefix */ private extractPathFromUrl(url: string): string { - const basePath = getBasePath(); - // Remove trailing slash from basePath for comparison (e.g., '/meet/' -> '/meet') - const basePathWithoutTrailingSlash = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath; - - // Helper to strip basePath from a path - const stripBasePath = (path: string): string => { - if (basePathWithoutTrailingSlash !== '' && path.startsWith(basePathWithoutTrailingSlash)) { - return path.slice(basePathWithoutTrailingSlash.length) || '/'; - } - - return path; - }; - // If already a path, strip basePath and return if (url.startsWith('/')) { - return stripBasePath(url); + return this.stripBasePath(url); } try { const urlObj = new URL(url); - const pathname = stripBasePath(urlObj.pathname); + const pathname = this.stripBasePath(urlObj.pathname); return pathname + urlObj.search + urlObj.hash; } catch { // If URL parsing fails, assume it's already a path @@ -285,6 +272,24 @@ export class RoomRepository extends BaseRepos } } + /** + * Strips the basePath from a given path if it starts with it. + * + * @param path - The path to process + * @returns The path without the basePath prefix + */ + private stripBasePath(path: string): string { + const basePath = getBasePath(); + // Remove trailing slash from basePath for comparison (e.g., '/meet/' -> '/meet') + const basePathWithoutTrailingSlash = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath; + + if (basePathWithoutTrailingSlash && path.startsWith(basePathWithoutTrailingSlash)) { + return path.slice(basePathWithoutTrailingSlash.length) || '/'; + } + + return path; + } + /** * Enriches room data by adding the base URL to access URLs. * Converts MongoDB document to domain object.