mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
guh
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user