{"record":{"id":"2096b4cb2bc51b63","repo":"remix-run/remix","slug":"invalid-hostname-wildcard","errorCode":null,"errorMessage":"invalid-hostname-wildcard","messagePattern":"invalid-hostname-wildcard","errorType":"validation","errorClass":"CreateHrefError","httpStatus":null,"severity":"error","filePath":"packages/route-pattern/src/lib/href.ts","lineNumber":393,"sourceCode":"export function validateHostnameVariable(value: unknown): string {\n  let serialized = String(value)\n  for (let char of serialized) {\n    if (char === '.' || isInvalidHostnameParamChar(char)) {\n      throw new CreateHrefError({\n        type: 'invalid-hostname-variable',\n        value: serialized,\n        char,\n      })\n    }\n  }\n  return serialized\n}\n\nexport function validateHostnameWildcard(value: unknown): string {\n  let serialized = String(value)\n  for (let char of serialized) {\n    if (isInvalidHostnameParamChar(char)) {\n      throw new CreateHrefError({\n        type: 'invalid-hostname-wildcard',\n        value: serialized,\n        char,\n      })\n    }\n  }\n  return serialized\n}\n\nfunction isInvalidHostnameParamChar(char: string): boolean {\n  let code = char.charCodeAt(0)\n  return code <= 0x1f || code === 0x7f || HOSTNAME_PARAM_STRUCTURAL_CHARS.includes(char)\n}\n","sourceCodeStart":375,"sourceCodeEnd":407,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/route-pattern/src/lib/href.ts#L375-L407","documentation":"A value substituted for a hostname wildcard (`*`) in a pattern contained a character that is structurally invalid in a hostname (@ : / ? # %). Unlike a variable param, dots are fine for wildcards (they span multiple labels), but these reserved characters still break the URL.","triggerScenarios":"Calling href on a pattern like `https://*/path` with params { '*': 'host/path' } or any value containing @, :, /, ?, #, or %.","commonSituations":"Passing full URLs or URIs into a hostname wildcard param; interpolating user input with query strings or ports; port values mistakenly folded into the host string (the `:` is invalid).","solutions":["Pass only the hostname portion (scheme, path, query stripped)","Include the port in the pattern (`https://*:8080`) rather than in the wildcard value","Sanitize values to reject @ : / ? # % before building hrefs"],"exampleFix":"// before\nhref(pattern, { '*': 'example.com:8080' })\n\n// after\nhref(parseRoutePattern('https://*:8080/x'), { '*': 'example.com' })","handlingStrategy":"validation","validationCode":"function isCleanHostname(v: string) { return ![...v].some(c => '@:/?#%'.includes(c)) }","typeGuard":"function isHostnameWildcardValue(value: unknown): value is string {\n  return typeof value === 'string' && value.length > 0 && ![...value].some(c => '@:/?#%'.includes(c))\n}","tryCatchPattern":null,"preventionTips":["Pass host-only strings, never full URLs","Put ports in the pattern, not the wildcard value"],"tags":["route-pattern","href","hostname","wildcard","url"],"backgroundTag":"invalid-hostname-in-url","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}