santifer/career-ops · error · Error

senjob: URL must use HTTPS: ${url}

Error message

senjob: URL must use HTTPS: ${url}

What it means

The senjob provider enforces https: on every URL it fetches. assertSenjobUrl parses the URL and throws this error when parsed.protocol is anything other than 'https:'. It complements the hostname check and the redirect:'error' fetch option to pin all requests to a secure senjob.com.

Source

Thrown at providers/senjob.mjs:79

/** The machine-readable publication date, hidden next to its localized form. */
const HIDDEN_ISO_DATE_RE = /display:\s*none;?\s*"?>\s*(\d{4}-\d{2}-\d{2})\s*</i;

/** @param {any} ctx @param {number} ms */
function sleep(ctx, ms) {
  if (typeof ctx?.sleep === 'function') return ctx.sleep(ms);
  return new Promise((r) => setTimeout(r, ms));
}

/** @param {string} url */
function assertSenjobUrl(url) {
  let parsed;
  try {
    parsed = new URL(url);
  } catch {
    throw new Error(`senjob: invalid URL: ${url}`);
  }
  if (parsed.protocol !== 'https:') throw new Error(`senjob: URL must use HTTPS: ${url}`);
  if (parsed.hostname !== TRUSTED_HOST) {
    throw new Error(`senjob: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}`);
  }
  return url;
}

/**
 * Collapse a markup fragment to its visible text.
 * Comments are stripped FIRST: the anchor bodies carry `<!-- d ico postulez -->`
 * between the title and a spacer image, and a naive tag strip would leave the
 * comment body sitting inside the title.
 * @param {string} fragment
 * @returns {string}
 */
export function visibleText(fragment) {
  return decodeEntities(
    String(fragment ?? '')
      .replace(/<!--[\s\S]*?-->/g, ' ')

View on GitHub (pinned to 1696bec4d0)

Solutions

  1. Use https:// URLs — ideally build them with buildListUrl(page) rather than by hand
  2. Update any stored config/env value from http://senjob.com to https://senjob.com
  3. If you need plain http for debugging, intercept at the proxy layer; do not downgrade the URL scheme

Example fix

// before
const url = 'http://senjob.com/offres-d-emploi.php?page=2';
// after
const url = buildListUrl(2); // https://senjob.com/offres-d-emploi.php?page=2
Defensive patterns

Strategy: validation

Validate before calling

function isHttpsSenjobUrl(url) {
  try { return new URL(url).protocol === 'https:'; } catch { return false; }
}
if (!isHttpsSenjobUrl(url)) url = url.replace(/^http:/i, 'https:');

Type guard

function isHttps(url) {
  try { return new URL(url).protocol === 'https:'; } catch { return false; }
}

Try / catch

try {
  assertSenjobUrl(url);
} catch (err) {
  if (String(err.message).startsWith('senjob: URL must use HTTPS')) {
    console.error(`Non-https URL refused: ${err.message} — upgrade the scheme or use buildListUrl()`);
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: assertSenjobUrl called with an http://, ftp://, or otherwise non-https URL — typically a hand-built list URL like http://senjob.com/offres-d-emploi.php or a config value stored without the scheme upgrade.

Common situations: Hardcoding http:// in a local/dev override; a config migration that downgraded URLs; concatenating 'http://' + host when assembling URLs in custom code.

Related errors


AI-assisted analysis of santifer/career-ops@1696bec4d0 (2026-09-01). Data as JSON: /api/errors/90e7761867c2327e. Report an issue: GitHub.