Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324import { resolve } from "$app/paths";
// rest params arrive decoded, re-encode per segment or `#`/`?`/`%` corrupt// the urlexport const encodePathSegments = (path: string): string => path.split("/").map(encodeURIComponent).join("/");
export const baseName = (path: string): string => path.split("/").pop() ?? path;
export const rawBlobHref = (ownerHandle: string, repoName: string, ref: string, path: string) => resolve( `/${ownerHandle}/${repoName}/raw/${encodeURIComponent(ref)}/${encodePathSegments(path)}` as "/" );
export const blobHref = (ownerHandle: string, repoName: string, ref: string, path: string) => resolve( `/${ownerHandle}/${repoName}/blob/${encodeURIComponent(ref)}/${encodePathSegments(path)}` as "/" );
export const fileHistoryHref = (ownerHandle: string, repoName: string, ref: string, path: string) => resolve( `/${ownerHandle}/${repoName}/history/${encodeURIComponent(ref)}/${encodePathSegments(path)}` as "/" );