{"record":{"id":"8767dca3959a7724","repo":"jackwener/OpenCLI","slug":"label-must-be-an-hltv-org-url","errorCode":null,"errorMessage":"${label} must be an hltv.org URL","messagePattern":"(.+?) must be an hltv\\.org URL","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hltv/utils.js","lineNumber":17,"sourceCode":"import { ArgumentError, CommandExecutionError, EmptyResultError, TimeoutError } from '@jackwener/opencli/errors';\n\nexport const BASE = 'https://www.hltv.org';\n\nfunction isHltvHost(hostname) {\n  return hostname === 'hltv.org' || hostname === 'www.hltv.org';\n}\n\nfunction parseHltvUserUrl(raw, label) {\n  let url;\n  try {\n    url = new URL(raw);\n  } catch {\n    throw new ArgumentError(`${label} must be a valid hltv.org URL`);\n  }\n  if (!isHltvHost(url.hostname)) {\n    throw new ArgumentError(`${label} must be an hltv.org URL`);\n  }\n  return url;\n}\n\nexport const EVENT_TYPES = {\n  all: null,\n  majors: 'Majors',\n  bigEvents: 'BigEvents',\n  mvpEvents: 'MvpEvents',\n  lan: 'Lan',\n  online: 'Online',\n};\n\nexport const RANKING_FILTERS = {\n  all: null,\n  top5: 'Top5',\n  top10: 'Top10',\n  top20: 'Top20',","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hltv/utils.js#L1-L35","documentation":"parseHltvUserUrl's second check: the raw string parsed as a URL but its hostname is not an hltv.org host (per isHltvHost). The library refuses to scrape non-HLTV URLs and throws this ArgumentError with the parameter label. Raised from parseEventRef, parseTeamRef, parsePlayerRef and the url helper.","triggerScenarios":"Passing a URL from another site (e.g. liquipedia, bo3.gg), a subdomain not covered by isHltvHost (mirror/typosquat domain), or a crafted URL with an unexpected hostname to any of the ref parsers.","commonSituations":"Mixing data sources and passing another site's match URL; using hltv.com or a regional mirror instead of hltv.org; environment-specific base URL overrides pointing at a proxy; copy-paste from search results landing on an aggregator.","solutions":["Use an https://www.hltv.org URL (correct domain) for the ref","Check for typos in the domain (hltv.com vs hltv.org)","If using a proxy/mirror, map URLs back to hltv.org before parsing","Catch ArgumentError and validate the hostname with a guard before calling"],"exampleFix":"// before\nconst ref = parseTeamRef('https://www.hltv.com/team/4608/natus-vincere'); // wrong TLD\n// after\nconst ref = parseTeamRef('https://www.hltv.org/team/4608/natus-vincere');","handlingStrategy":"validation","validationCode":"function isHltvOrgUrl(raw) {\n  try { return new URL(raw).hostname === 'www.hltv.org' || new URL(raw).hostname.endsWith('.hltv.org'); }\n  catch { return false; }\n}\nif (!isHltvOrgUrl(input)) throw new Error('expected an hltv.org URL');","typeGuard":"function isHltvHostname(u) { try { const url = new URL(u); return /(^|\\.)hltv\\.org$/.test(url.hostname); } catch { return false; } }","tryCatchPattern":"try {\n  const ref = parseEventRef(raw);\n} catch (err) {\n  if (err instanceof ArgumentError && /must be an hltv\\.org URL/.test(err.message)) {\n    return fail(`wrong host, expected hltv.org: ${new URL(raw).hostname}`);\n  }\n  throw err;\n}","preventionTips":["Check the domain is hltv.org (not .com or mirrors) before parsing","Map third-party site URLs to their HLTV equivalents before use","Whitelist hosts in your own code so bad URLs fail early with context","Beware copy-pasted links from search results pointing to aggregators"],"tags":["argument-error","validation","url","wrong-host"],"backgroundTag":"invalid-url-input","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}