export function getPath(): string { const path = window.location.pathname.split('/'); // Handle /db/public/:db or /db/private/:db patterns if (path.length >= 4 && path[1] === 'db') { return path[3]; } // Legacy pattern /db/:db if (path.length == 3 && path[1]) { return path[2]; } return null; } /** * Check if the current path is a public database * Public paths: /db/public/:db * Private paths: /db/private/:db */ export function isPublicPath(): boolean { const path = window.location.pathname.split('/'); return path.length >= 3 && path[1] === 'db' && path[2] === 'public'; } /** * Get the database type from the current path */ export function getDbType(): 'public' | 'private' | null { const path = window.location.pathname.split('/'); if (path.length >= 3 && path[1] === 'db') { if (path[2] === 'public') return 'public'; if (path[2] === 'private') return 'private'; } return null; } /** * Get the full database path for PouchDB sync * Returns: public-{dbname} or private-{dbname} * Uses dash separator instead of slash for express-pouchdb compatibility */ export function getRemoteDbPath(): string | null { const path = window.location.pathname.split('/'); if (path.length >= 4 && path[1] === 'db') { const type = path[2]; // 'public' or 'private' const dbName = path[3]; return `${type}-${dbName}`; } return null; } export function getParameter(name: string) { const searchParams = new URLSearchParams(window.location.search); return searchParams.get(name); } export function viewOnly(): boolean { return getParameter('viewonly') == 'true'; }