{"record":{"id":"c704aee728af0a80","repo":"santifer/career-ops","slug":"4dayweek-url-must-use-https-url","errorCode":null,"errorMessage":"4dayweek: URL must use HTTPS: ${url}","messagePattern":"4dayweek: URL must use HTTPS: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/4dayweek.mjs","lineNumber":55,"sourceCode":"      if (parsed.protocol === 'https:' && parsed.hostname === TRUSTED_HOST) {\n        return { url: FEED_BASE };\n      }\n    } catch {\n      // Ignore malformed URLs; another provider may still claim the entry.\n    }\n  }\n  return null;\n}\n\n/** @param {string} url */\nfunction assertFourDayUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`4dayweek: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`4dayweek: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`4dayweek: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n/** Resolve the page cap: a positive integer `max_pages` on the entry, capped. */\nfunction resolveMaxPages(entry) {\n  const v = entry?.max_pages;\n  if (Number.isInteger(v) && v > 0) return Math.min(v, MAX_PAGES_CAP);\n  return DEFAULT_MAX_PAGES;\n}\n\n// NaN-safe: posted is epoch SECONDS → ms; anything non-finite yields undefined.\nfunction toEpochMs(seconds) {\n  return Number.isFinite(seconds) ? seconds * 1000 : undefined;\n}\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/4dayweek.mjs#L37-L73","documentation":"After successfully parsing, assertFourDayUrl() enforces that the URL uses HTTPS (parsed.protocol === 'https:'). Any http:// (or other scheme like ftp:) URL passed to the 4dayweek provider throws this error. The library refuses plaintext HTTP to avoid insecure fetches and to guarantee requests only go to the expected origin.","triggerScenarios":"Calling any 4dayweek provider function with a URL whose scheme is 'http:' — most often a hand-written config entry 'http://4dayweek.io/...', a link copied from a page that downgraded the scheme, or legacy config predating the HTTPS requirement.","commonSituations":"portals.yml or docs containing an http:// link copied years ago; a proxy/dev environment rewriting https:// to http://; string manipulation that replaced the scheme; hardcoding localhost http URLs from local testing into shared config.","solutions":["Change the URL scheme to https:// (e.g. https://4dayweek.io/jobs)","Search your config (portals.yml and any custom provider config) for 'http://4dayweek' and fix all occurrences","If a source system only serves http, locate the canonical HTTPS URL of the same resource — the provider will not accept the insecure one","Validate before calling: assert new URL(url).protocol === 'https:' in your own config loader to fail fast at startup"],"exampleFix":"// before\nconst url = 'http://4dayweek.io/jobs';\n// after\nconst url = 'https://4dayweek.io/jobs';","handlingStrategy":"validation","validationCode":"// Enforce HTTPS in your config loader before the provider sees the value\nconst u = new URL(cfg.url);\nif (u.protocol !== 'https:') throw new Error(`4dayweek URL must be https:// (got ${u.protocol}) in ${configKey}`);","typeGuard":"function isHttpsUrl(v) {\n  try { return new URL(v).protocol === 'https:'; } catch { return false; }\n}","tryCatchPattern":"try {\n  await fetchFourDayWeek(url);\n} catch (e) {\n  if (String(e.message).startsWith('4dayweek: URL must use HTTPS')) {\n    console.error(`Fix config: '${url}' must start with https://.`);\n  } else throw e;\n}","preventionTips":["Standardize on https:// in all stored config; grep config files for 'http://' during setup reviews","Normalize links when copying from browsers or docs — some sources emit http:// variants","Add a startup assertion that all provider URLs are https, so misconfigurations fail before any fetch","Never hardcode localhost http URLs in shared config; keep dev/test endpoints in separate settings"],"tags":["validation","url","https","provider"],"backgroundTag":"invalid-url","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}