{"version":3,"file":"join_host_and_path.mjs","names":[],"sources":["../../src/internal/join_host_and_path.ts"],"sourcesContent":["/** @internal */\nconst SLASH = 0x2f;\n\n/**\n * Normalize a route path to exactly one leading separator.\n *\n * `@nestia/sdk` always emits a leading-slash path, but a hand-written\n * {@link IFetchRoute.path} may omit it, and a server-composed path may carry\n * several. Interior separators are left alone: only the boundary is\n * normalized.\n *\n * @internal\n */\nexport const normalize_route_path = (path: string): string => {\n  let start: number = 0;\n  while (start < path.length && path.charCodeAt(start) === SLASH) ++start;\n  return `/${path.slice(start)}`;\n};\n\n/**\n * Join a host address and a route path with exactly one separator.\n *\n * `IConnection.host` may or may not end with a separator, and the route path\n * may or may not begin with one; all four spellings must produce the same URL.\n * `new URL()` does not collapse a doubled separator inside a pathname, so the\n * join has to be exact — `http://localhost:3000/` plus `/health` must not\n * become `http://localhost:3000//health`, which most routers treat as an\n * unmapped path.\n *\n * Both boundaries are scanned rather than matched with a regular expression.\n * `host` is caller-supplied, and a trailing-separator pattern backtracks\n * polynomially over a run of separators, so a pathological host would cost\n * quadratic time on every request.\n *\n * @internal\n */\nexport const join_host_and_path = (host: string, path: string): string => {\n  let end: number = host.length;\n  while (end > 0 && host.charCodeAt(end - 1) === SLASH) --end;\n  return `${host.slice(0, end)}${normalize_route_path(path)}`;\n};\n"],"mappings":";;AACA,MAAM,QAAQ;;;;;;;;;;;AAYd,MAAa,wBAAwB,SAAyB;CAC5D,IAAI,QAAgB;CACpB,OAAO,QAAQ,KAAK,UAAU,KAAK,WAAW,KAAK,MAAM,OAAO,EAAE;CAClE,OAAO,IAAI,KAAK,MAAM,KAAK;AAC7B;;;;;;;;;;;;;;;;;;AAmBA,MAAa,sBAAsB,MAAc,SAAyB;CACxE,IAAI,MAAc,KAAK;CACvB,OAAO,MAAM,KAAK,KAAK,WAAW,MAAM,CAAC,MAAM,OAAO,EAAE;CACxD,OAAO,GAAG,KAAK,MAAM,GAAG,GAAG,IAAI,qBAAqB,IAAI;AAC1D"}