Skip to content

gitflarePublicPartly agent-ready50

cf-workflows-pipeline

Durable content pipeline on Cloudflare Workflows: ingest, extract, summarise with Workers AI via AI Gateway, human approval, publish.

Fix pipeline runs failing at ingest (steps.attempt NOT NULL)629b2fa
TypeScript17 lines1012 B
export function validateUrl(input: string): { ok: true; url: string } | { ok: false; error: string } {  let u: URL;  try { u = new URL(input); } catch { return { ok: false, error: "invalid url" }; }  if (u.protocol !== "http:" && u.protocol !== "https:") return { ok: false, error: "only http/https allowed" };  const h = u.hostname.toLowerCase().replace(/^\[|\]$/g, "");  if (h === "localhost" || h.endsWith(".localhost") || h.endsWith(".internal")) return { ok: false, error: "private host" };  const m = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(h);  if (m) {    const [a, b] = [Number(m[1]), Number(m[2])];    if (a === 10 || a === 127 || a === 0 || (a === 169 && b === 254) || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168))      return { ok: false, error: "private ip" };  }  if (h.includes(":") && (h === "::1" || h === "::" || /^f[cd]/.test(h) || /^fe80/.test(h) || h.startsWith("::ffff:")))    return { ok: false, error: "private ip" };  return { ok: true, url: u.toString() };}