INNER CODE UNIT · JavaScript

hostOf

LeyckerS/moondownloader · web/app.js:180

const hostOf = (url) => {
  const m = /^[a-z]+:\/\/([^/?#]+)/i.exec(url.trim());
  return m ? m[1].toLowerCase() : "";
};
const classify = (url) => {
  const h = hostOf(url);
  if (h.includes("datanodes.to")) return "dn";
  if (h.includes("fuckingfast.co")) return "ff";
  return "ot";
};
const escapeHtml = (s) => s.replace(/[&<>]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;" }[c]));

/* Middle ellipsis: these filenames differ only in the last few characters, so
   clipping the tail would make every row look identical. */
function elide(name, head = 34, tail = 22) {
  if (name.length <= head + tail + 1) return name;
  return name.slice(0, head) + "…" + name.slice(-tail);
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…