{"record":{"id":"a1c9c4233bdbe553","repo":"jackwener/OpenCLI","slug":"hltv-parser-returned-an-off-domain-url-url-tost","errorCode":null,"errorMessage":"HLTV parser returned an off-domain URL: ${url.toString()}","messagePattern":"HLTV parser returned an off-domain URL: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/hltv/utils.js","lineNumber":109,"sourceCode":"  if (!match) return null;\n  const n = Number(match[0]);\n  return Number.isFinite(n) ? n : null;\n}\n\nexport function parseMoneyUsd(value) {\n  return parseNumber(String(value ?? '').replace(/\\$/g, ''));\n}\n\nexport function absolutizeUrl(value) {\n  if (!value) return null;\n  let url;\n  try {\n    url = new URL(value, BASE);\n  } catch {\n    throw new CommandExecutionError('HLTV parser returned a malformed URL');\n  }\n  if (!isHltvHost(url.hostname)) {\n    throw new CommandExecutionError(`HLTV parser returned an off-domain URL: ${url.toString()}`);\n  }\n  return url.toString();\n}\n\nexport function extractIdFromUrl(url, kind) {\n  if (!url) return null;\n  let parsed;\n  try {\n    parsed = new URL(url, BASE);\n  } catch {\n    return null;\n  }\n  if (!isHltvHost(parsed.hostname)) return null;\n  const path = parsed.pathname;\n  const patterns = {\n    player: /^\\/player\\/(\\d+)\\//,\n    team: /^\\/team\\/(\\d+)\\//,\n    event: /^\\/events\\/(\\d+)\\//,","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hltv/utils.js#L91-L127","documentation":"absolutizeUrl rejects resolved URLs whose hostname is not an HLTV host, throwing CommandExecutionError with the offending URL. This guards against the scraper emitting links to third-party domains (ads, sponsors, redirects) which would break downstream id extraction.","triggerScenarios":"A parsed link points to an external domain (partner/sponsor banner, twitter/steam link) that the selector mistakenly captured; malicious or altered HTML.","commonSituations":"HLTV pages embedding sponsored or cross-domain links in areas the parser scans; parser bug after a page redesign; custom proxies rewriting hostnames.","solutions":["Update to the latest library version so selectors skip non-HLTV links","Check the URL printed in the message to identify which page element produced it and avoid that command/input","Report the offending URL/page to the maintainers","Use commands/options that filter to the specific entity type you need"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function isHltvUrl(u) { try { return /(^|\\.)hltv\\.org$/.test(new URL(u, 'https://www.hltv.org').hostname); } catch { return false; } }\nif (result.url && !isHltvUrl(result.url)) throw new Error('unexpected off-domain link');","typeGuard":"const isHltvHost = (hostname) => hostname === 'hltv.org' || hostname.endsWith('.hltv.org');","tryCatchPattern":"try {\n  const match = await hltv.match(id);\n} catch (e) {\n  if (e.name === 'CommandExecutionError' && e.message.includes('off-domain URL')) {\n    const badUrl = e.message.split(': ')[1];\n    console.error(`Parser captured non-HLTV link: ${badUrl}`);\n  } else throw e;\n}","preventionTips":["Update the library when HLTV adds new embedded/sponsor links","Inspect the offending URL in the message to find the triggering page element","Filter parsed links client-side before further processing"],"tags":["scraping","url-parsing","security","hltv"],"backgroundTag":"off-domain-url","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}