Fixes based off PR review comments

This commit is contained in:
0x464e
2026-03-20 21:19:00 +02:00
parent 738197b184
commit dd5ad11a6e
3 changed files with 23 additions and 14 deletions
+9 -6
View File
@@ -1,3 +1,5 @@
import { baseUrl } from "@/api/baseUrl.ts";
export const RECORDING_REVIEW_LINK_PARAM = "timestamp";
export type RecordingReviewLinkState = {
@@ -43,11 +45,12 @@ export function createRecordingReviewUrl(
pathname: string,
state: RecordingReviewLinkState,
): string {
const url = new URL(globalThis.location.href);
const normalizedPathname = pathname.startsWith("/")
? pathname
: `/${pathname}`;
const reviewLink = `${state.camera}_${Math.floor(state.timestamp)}`;
const url = new URL(baseUrl);
url.pathname = pathname.startsWith("/") ? pathname : `/${pathname}`;
url.searchParams.set(
RECORDING_REVIEW_LINK_PARAM,
`${state.camera}_${Math.floor(state.timestamp)}`,
);
return `${url.origin}${normalizedPathname}?${RECORDING_REVIEW_LINK_PARAM}=${reviewLink}`;
return url.toString();
}