{"record":{"id":"6de7395a9a37a849","repo":"santifer/career-ops","slug":"wttj-invalid-url-url","errorCode":null,"errorMessage":"wttj: invalid URL: ${url}","messagePattern":"wttj: invalid URL: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/wttj.mjs","lineNumber":38,"sourceCode":"//     enabled: true\n//\n// Each hit maps to the normalized Job shape; salary_yearly_minimum (when\n// present) is attached as `salary: {min, max, currency}` so scan.mjs's\n// salary_filter can gate on it.\n\nconst ENV_URL = 'https://www.welcometothejungle.com/api/env';\nconst SITE_ORIGIN = 'https://www.welcometothejungle.com';\nconst INDEX = 'wttj_jobs_production_en';\nconst DEFAULT_MAX_HITS = 100;\nconst MAX_HITS_CAP = 200;\n\n/** Pin a URL to an expected https host. */\nfunction assertHost(url, host, label) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`wttj: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`wttj: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== host.toLowerCase()) {\n    throw new Error(`wttj: untrusted ${label} hostname \"${parsed.hostname}\" — must be ${host}`);\n  }\n  return url;\n}\n\n/**\n * Parse the `window.env = {...}` payload served by /api/env and extract the\n * Algolia application id + client search key.\n * @param {string} text\n * @returns {{ appId: string, apiKey: string }}\n */\nexport function parseEnvPayload(text) {\n  const start = text.indexOf('{');\n  const end = text.lastIndexOf('}');\n  if (start === -1 || end <= start) throw new Error('wttj: /api/env payload has no JSON object');","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/wttj.mjs#L20-L56","documentation":"assertHost pins WTTJ/Algolia URLs to expected https hosts. This branch fires when new URL(url) throws. In production this is only reachable if ENV_URL is malformed, or — defensively — if appId validation let an unparseable Algolia host through (it cannot, given the ^[A-Z0-9]{6,16}$i guard on appId).","triggerScenarios":"A maintainer breaks the ENV_URL constant; an empty appId is interpolated into the algolia host (defensive — the app-id regex already prevents this).","commonSituations":"Refactor of ENV_URL; a bad merge.","solutions":["Restore ENV_URL to https://www.welcometothejungle.com/api/env.","Keep the appId regex so algoliaHost is always well-formed."],"exampleFix":"// before\nconst ENV_URL = 'www.welcometothejungle.com/api/env';\n// after\nconst ENV_URL = 'https://www.welcometothejungle.com/api/env';","handlingStrategy":"validation","validationCode":"try { new URL(ENV_URL); }\ncatch { throw new Error(`wttj: ENV_URL constant is malformed: ${ENV_URL}`); }","typeGuard":"const isAbsoluteUrl = (s) => { try { new URL(s); return true; } catch { return false; } };","tryCatchPattern":null,"preventionTips":["Keep ENV_URL a module constant on https.","Keep the appId regex tight so algoliaHost is always well-formed."],"tags":["validation","url","ssrf-guard","wttj","invariant"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}