laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
42 lines (41 loc) • 1.21 kB
JavaScript
"use client";
function i(t) {
if (!t) return "";
const e = t.split(/[?#]/)[0].split("/").pop() || "", s = e.lastIndexOf(".");
return s >= 0 ? e.substring(s + 1).toLowerCase() : "";
}
const o = /* @__PURE__ */ new Set([
"jpg",
"jpeg",
"png",
"gif",
"webp",
"bmp",
"svg",
"tiff"
]), a = /* @__PURE__ */ new Set(["pdf"]), r = /* @__PURE__ */ new Set(["txt", "md", "csv", "log", "json"]), c = /* @__PURE__ */ new Set(["mp3", "wav", "ogg", "m4a", "aac"]), f = /* @__PURE__ */ new Set(["mp4", "webm", "ogv", "mov"]);
function p(t) {
return !!t && /^(https?:)?\/\//i.test(t);
}
function u(t) {
return `https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(t)}`;
}
function d({
mimeType: t,
filename: n,
url: e
}) {
const s = i(n || e);
return t?.startsWith("image/") || o.has(s) ? "image" : t === "application/pdf" || a.has(s) ? "pdf" : t?.startsWith("audio/") || c.has(s) ? "audio" : t?.startsWith("video/") || f.has(s) ? "video" : r.has(s) || t?.startsWith("text/") ? "text" : "office";
}
export {
c as audioExts,
i as getExt,
u as getOfficeEmbedUrl,
d as guessKind,
o as imageExts,
p as isHttpUrl,
a as pdfExts,
r as textExts,
f as videoExts
};