Rebasely Beta: data may be purged

examples/live-notes Public

TypeScript · 12 lines · 507 B · at 6e3dc76

// The Worker's routes, kept apart from index.ts so they can be tested without the runtime.export type Route = { kind: "note"; id: string } | { kind: "socket"; id: string } | null;// Note ids are what people put in a link: letters, digits, dashes and underscores.const NOTE = /^\/notes\/([A-Za-z0-9_-]{1,64})(\/ws)?$/;export function route(pathname: string): Route {  const m = NOTE.exec(pathname);  if (!m) return null;  return m[2] ? { kind: "socket", id: m[1] } : { kind: "note", id: m[1] };}