| 24 | export const baseUrl = "https://opencode.ai" |
| 25 | |
| 26 | function normalizeDataPathname(pathname: string) { |
| 27 | const next = localeStrip(pathname) |
| 28 | const path = next.startsWith("/") ? next : `/${next}` |
| 29 | const trailing = path.endsWith("/") |
| 30 | const segments = path.split("/").filter(Boolean) |
| 31 | const dataIndex = segments.lastIndexOf(basePath.slice(1)) |
| 32 | const rest = dataIndex === -1 ? segments : segments.slice(dataIndex + 1) |
| 33 | const normalized = `${basePath}${rest.length ? `/${rest.join("/")}` : "/"}` |
| 34 | if (trailing && !normalized.endsWith("/")) return `${normalized}/` |
| 35 | return normalized |
| 36 | } |
| 37 | |
| 38 | export function strip(pathname: string) { |
| 39 | return normalizeDataPathname(pathname) |