Files
erika/lib/realtime/deployment-refresh.ts
T

28 lines
667 B
TypeScript

export const UPDATE_HASH = "#update";
export function checkDeploymentVersion(
currentVersion: string | null,
incomingVersion: string,
) {
return {
version: incomingVersion,
hasUpdate:
currentVersion !== null && currentVersion !== incomingVersion,
};
}
export function shouldReloadPath(prefix: string | null, pathname: string) {
return prefix === null || pathname.startsWith(prefix);
}
export function normalizeReloadPrefix(prefix: string | null) {
if (prefix === null) return null;
const normalized = prefix.trim();
if (!normalized.startsWith("/")) {
throw new Error("Reload path must start with /");
}
return normalized;
}