{"version":3,"sources":["../../../../src/server/lib/encode-header-safe.ts"],"sourcesContent":["/**\n * Percent-encode every character other than horizontal tab and printable ASCII\n * so a value can be safely serialized into an HTTP header.\n *\n * Node's `validateHeaderValue` and `fetch`'s ByteString conversion accept\n * different character ranges. Restricting values to `\\t\\x20-\\x7e` produces a\n * conservative representation that both can serialize. Characters outside a\n * transport's accepted range (Hebrew, Arabic, Chinese, emoji, …) would\n * otherwise throw `ERR_INVALID_CHAR` or a `TypeError`, which crashes ISR or\n * fails a cache read on every affected request.\n *\n * Cache tags are encoded at the public boundaries — tag construction\n * (`getImplicitTags`, `validateTags`) and invalidation input\n * (`revalidatePath`, `revalidateTag`, `updateTag`) — so storage, comparison,\n * and the wire all see the same canonical form.\n *\n * The class is narrower than either transport accepts. Everything inside it\n * passes through byte-for-byte, including `,`, `/`, `%`, `[`, `]`, `_`, `-` and\n * `\\t`, which preserves the comma-separated header format and the\n * dynamic-segment markers in derived tags (`_N_T_/[slug]/page`).\n *\n * Properties:\n * - Fast-path: input that already fits the class is returned unchanged. This\n *   makes the encoder idempotent on already-encoded `%xx` sequences.\n * - Matches *runs* of out-of-class code units so surrogate pairs (e.g. an\n *   emoji) are handed to `encodeURIComponent` as a complete code point — a\n *   per-code-unit regex would split the pair and throw `URIError`.\n */\nconst OUT_OF_CLASS_CHAR = /[^\\t\\x20-\\x7e]/\nconst OUT_OF_CLASS_RUN = /[^\\t\\x20-\\x7e]+/g\n\nexport function encodeHeaderSafe(value: string): string {\n  return OUT_OF_CLASS_CHAR.test(value)\n    ? value.replace(OUT_OF_CLASS_RUN, (run) => encodeURIComponent(run))\n    : value\n}\n"],"names":["OUT_OF_CLASS_CHAR","OUT_OF_CLASS_RUN","encodeHeaderSafe","value","test","replace","run","encodeURIComponent"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,MAAMA,oBAAoB;AAC1B,MAAMC,mBAAmB;AAEzB,OAAO,SAASC,iBAAiBC,KAAa;IAC5C,OAAOH,kBAAkBI,IAAI,CAACD,SAC1BA,MAAME,OAAO,CAACJ,kBAAkB,CAACK,MAAQC,mBAAmBD,QAC5DH;AACN","ignoreList":[0]}