/** * Purpose: WEB_API_AUTH_FREE_PATHS supports auth-free-paths.ts by holding or executing the web api auth free paths page or API role. * Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow. */ export const WEB_API_AUTH_FREE_PATHS = [ '/user/login', '/user/register', '/user/check/', '/user/refresh-token', '/user/send-verification-code', '/user/phone-login', '/user/wechat-mini/', '/user/reset-password-by-phone', '/legal-agreement/current', '/api/legal-agreement/current', '/product/get/', '/product/list/', '/comment/list/product/', '/nail-artist/', '/shop/get/', '/shop/trust-profile/', '/shop/list', '/shop/list/public', '/shop/list/simple', '/tag/list/all', '/tag/list/filter-options', '/file/get-signed-url/', ] as const /** * Purpose: normalizePathname supports auth-free-paths.ts by holding or executing the normalize pathname page or API role. * Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow. */ const normalizePathname = (url?: string) => { const raw = String(url || '') const withoutHash = raw.split('#')[0] || '' const withoutQuery = withoutHash.split('?')[0] || '' try { return new URL(withoutQuery, 'http://jayucloud-artlist.local').pathname } catch { return withoutQuery.startsWith('/') ? withoutQuery : `/${withoutQuery}` } } /** * Purpose: matchesAuthFreePath supports auth-free-paths.ts by holding or executing the matches auth free path page or API role. * Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow. */ const matchesAuthFreePath = (url: string | undefined, path: string) => { const pathname = normalizePathname(url) if (path.endsWith('/')) { return pathname === path.slice(0, -1) || pathname.startsWith(path) } return pathname === path } /** * Purpose: isApiAuthFreePath supports auth-free-paths.ts by holding or executing the is api auth free path page or API role. * Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow. */ export const isApiAuthFreePath = (url?: string) => { return WEB_API_AUTH_FREE_PATHS.some(path => matchesAuthFreePath(url, path)) }