UNPKG

@pdf-viewer/react

Version:

A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.

17 lines (16 loc) 511 B
const o = /^([^\w]*)(javascript|data|vbscript)/im, i = /&#(\w+)(^\w|;)?/g, a = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim, u = /^([^:]+):/gm, m = (r) => r.replace(i, (e, t) => String.fromCharCode(t)), C = (r, e = "about:blank") => { const t = m(r || "").replace(a, "").trim(); if (!t) return e; const n = t[0]; if (n === "." || n === "/") return t; const s = t.match(u); if (!s) return t; const c = s[0]; return o.test(c) ? e : t; }; export { C as sanitizeExternalUrl };