This commit is contained in:
legop3
2025-11-18 17:07:14 -05:00
parent 978df8fb62
commit 4cbcdef9c2
+21 -7
View File
@@ -22,17 +22,31 @@ function getPathPrefix() {
} }
const whepPathPrefix = getPathPrefix().replace(/\/+$/, '').replace(/^\/+/, ''); const whepPathPrefix = getPathPrefix().replace(/\/+$/, '').replace(/^\/+/, '');
const whepPrefixSegments = whepPathPrefix ? whepPathPrefix.split('/').filter(Boolean) : [];
function extractRoverId(path) { function extractRoverId(path) {
let clean = (path || '').replace(/^\//, ''); const segments = (path || '').split('/').filter(Boolean);
if (!clean) return ''; if (!segments.length) {
if (clean.endsWith('/whep')) { return '';
clean = clean.slice(0, -'/whep'.length);
} }
if (whepPathPrefix && clean.startsWith(`${whepPathPrefix}/`)) {
clean = clean.slice(whepPathPrefix.length + 1); let start = 0;
if (
whepPrefixSegments.length &&
whepPrefixSegments.every((segment, idx) => segments[idx] === segment)
) {
start = whepPrefixSegments.length;
} }
return clean;
let end = segments.length;
if (segments[end - 1] === 'whep') {
end -= 1;
}
if (end - start !== 1) {
return '';
}
return segments[start] || '';
} }
function canView(socket) { function canView(socket) {