fix: generate link for companion

This commit is contained in:
Carlos Valente
2025-09-04 06:09:51 +02:00
committed by Alex Christoffer Rasmussen
parent 6ff06b21a8
commit 763080cd4d
4 changed files with 25 additions and 13 deletions
@@ -64,18 +64,21 @@ export function generateShareUrl(
): URL {
const url = new URL(baseUrl);
// if the config is locked and we are in a preset, we hide the canonical path
const shouldMaskPath = Boolean(preset) && (canonicalPath === OntimeView.Cuesheet || lockConfig);
const maybePresetPath = shouldMaskPath ? `preset/${preset}` : preset || canonicalPath;
url.pathname = prefix ? `${prefix}/${maybePresetPath}` : maybePresetPath;
// companion links point to the root
if (canonicalPath !== '<<companion>>') {
// if the config is locked and we are in a preset, we hide the canonical path
const shouldMaskPath = Boolean(preset) && (canonicalPath === OntimeView.Cuesheet || lockConfig);
const maybePresetPath = shouldMaskPath ? `preset/${preset}` : preset || canonicalPath;
url.pathname = prefix ? `${prefix}/${maybePresetPath}` : maybePresetPath;
if (lockNav) {
url.searchParams.append('n', '1');
}
}
if (authenticate && hash) {
url.searchParams.append('token', hash);
}
if (lockNav) {
url.searchParams.append('n', '1');
}
return url;
}