UNPKG

@kaifronsdal/transcript-viewer

Version:

A web-based viewer for AI conversation transcripts with rollback support

2 lines (1 loc) 1.07 kB
import{s as a}from"./BE0jUqnW.js";const o=()=>{const t=a;return{page:{subscribe:t.page.subscribe},navigating:{subscribe:t.navigating.subscribe},updated:t.updated}},u={subscribe(t){return o().page.subscribe(t)}};function i(t){return t.replace(/\\/g,"/")}function p(t){return`/transcript/${i(t||"").split("/").filter(Boolean).map(encodeURIComponent).join("/")}`}function f(t){return t?i(t):null}function h(t){if(!t||t.length===0)throw new Error("Invalid path: empty path segments");const e=t.map(s=>{try{return decodeURIComponent(s)}catch{throw new Error(`Invalid URL encoding in path segment: ${s}`)}}).join("/");if(!e||!e.endsWith(".json"))throw new Error(`Invalid file path: ${e}`);if(e.startsWith("/"))throw new Error("Invalid file path: must be relative, not absolute");if(e.includes("../"))throw new Error("Invalid file path: directory traversal is not allowed");const n=e.lastIndexOf("/");if(!(n>=0?e.slice(n+1):e).startsWith("transcript_"))throw new Error('Invalid file path: filename must start with "transcript_"');return e}export{u as a,p as b,f as n,h as p};