jackwener/OpenCLI · error · CommandExecutionError
HLTV parser returned an off-domain URL: ${url.toString()}
Error message
HLTV parser returned an off-domain URL: ${url.toString()} What it means
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.
Source
Thrown at clis/hltv/utils.js:109
if (!match) return null;
const n = Number(match[0]);
return Number.isFinite(n) ? n : null;
}
export function parseMoneyUsd(value) {
return parseNumber(String(value ?? '').replace(/\$/g, ''));
}
export function absolutizeUrl(value) {
if (!value) return null;
let url;
try {
url = new URL(value, BASE);
} catch {
throw new CommandExecutionError('HLTV parser returned a malformed URL');
}
if (!isHltvHost(url.hostname)) {
throw new CommandExecutionError(`HLTV parser returned an off-domain URL: ${url.toString()}`);
}
return url.toString();
}
export function extractIdFromUrl(url, kind) {
if (!url) return null;
let parsed;
try {
parsed = new URL(url, BASE);
} catch {
return null;
}
if (!isHltvHost(parsed.hostname)) return null;
const path = parsed.pathname;
const patterns = {
player: /^\/player\/(\d+)\//,
team: /^\/team\/(\d+)\//,
event: /^\/events\/(\d+)\//,View on GitHub (pinned to 49907e53dc)
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
Defensive patterns
Strategy: try-catch
Validate before calling
function isHltvUrl(u) { try { return /(^|\.)hltv\.org$/.test(new URL(u, 'https://www.hltv.org').hostname); } catch { return false; } }
if (result.url && !isHltvUrl(result.url)) throw new Error('unexpected off-domain link'); Type guard
const isHltvHost = (hostname) => hostname === 'hltv.org' || hostname.endsWith('.hltv.org'); Try / catch
try {
const match = await hltv.match(id);
} catch (e) {
if (e.name === 'CommandExecutionError' && e.message.includes('off-domain URL')) {
const badUrl = e.message.split(': ')[1];
console.error(`Parser captured non-HLTV link: ${badUrl}`);
} else throw e;
} Prevention
- 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
When it happens
Trigger: A parsed link points to an external domain (partner/sponsor banner, twitter/steam link) that the selector mistakenly captured; malicious or altered HTML.
Common situations: HLTV pages embedding sponsored or cross-domain links in areas the parser scans; parser bug after a page redesign; custom proxies rewriting hostnames.
Related errors
- HLTV parser returned a malformed URL
- Expected a trusted HTTPS bilibili.com video URL without cred
- player must be like 3741/niko, a player URL, or a stats play
- match must be an HLTV match, stats series, or mapstats URL
- hltv match-map parser returned an unexpected shape
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a1c9c4233bdbe553.
Report an issue: GitHub.