mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
guh
This commit is contained in:
@@ -14,14 +14,14 @@ function buildWhepUrl(roverId) {
|
||||
if (!base) {
|
||||
return '';
|
||||
}
|
||||
let origin;
|
||||
let prefix = base;
|
||||
try {
|
||||
const parsed = new URL(base);
|
||||
origin = parsed.origin;
|
||||
prefix = `${parsed.origin}${parsed.pathname}`;
|
||||
} catch (err) {
|
||||
origin = base.replace(/\/.*$/, '');
|
||||
// leave prefix as-is when URL parsing fails; fall back to string cleanup below
|
||||
}
|
||||
const cleanBase = origin.replace(/\/$/, '');
|
||||
const cleanBase = prefix.replace(/\/+$/, '');
|
||||
const encodedId = encodeURIComponent(roverId);
|
||||
return `${cleanBase}/${encodedId}/whep`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user