{"version":3,"file":"url.cjs","names":[],"sources":["../src/url.ts"],"sourcesContent":["/**\n * Resolve an upstream URL by joining a base URL with a request pathname.\n *\n * Uses RFC 3986 relative resolution: the base URL's path prefix is preserved\n * by ensuring a trailing slash (marking it as a \"directory\") and stripping the\n * leading slash from the pathname (making it relative, not absolute).\n *\n * Without this, `new URL(\"/v1/chat/completions\", \"https://openrouter.ai/api\")`\n * resolves to `https://openrouter.ai/v1/chat/completions` — losing the `/api` prefix.\n */\nexport function resolveUpstreamUrl(base: string, pathname: string): URL {\n  const normalizedBase = base.endsWith(\"/\") ? base : base + \"/\";\n  const relativePath = pathname.startsWith(\"/\") ? pathname.slice(1) : pathname;\n  return new URL(relativePath, normalizedBase);\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAgB,mBAAmB,MAAc,UAAuB;CACtE,MAAM,iBAAiB,KAAK,SAAS,IAAI,GAAG,OAAO,OAAO;CAC1D,MAAM,eAAe,SAAS,WAAW,IAAI,GAAG,SAAS,MAAM,EAAE,GAAG;AACpE,QAAO,IAAI,IAAI,cAAc,eAAe"}