MCPcopy Create free account
hub / github.com/ScattrdBlade/bigFileUpload / getUrlExtension

Function getUrlExtension

utils/getMediaUrl.ts:94–109  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

92}
93
94export function getUrlExtension(url: string): string | undefined {
95 if (!url.startsWith("https:") && !url.startsWith("http:")) {
96 url = "https:" + url;
97 }
98 try {
99 let { pathname } = new URL(url);
100 pathname = pathname.replace(/\/+$/, "");
101 const lastSegment = pathname.split("/").pop() || "";
102 if (!lastSegment.includes(".")) return undefined;
103 const ext = lastSegment.split(".").pop()?.toLowerCase();
104 if (!ext || ext.length === 0 || ext.length > 10) return undefined;
105 return ext;
106 } catch {
107 return undefined;
108 }
109}
110
111export function isSupported(url: string): boolean {
112 const ext = getUrlExtension(url);

Callers 3

shouldProxyEmbedUrlFunction · 0.90
normalizeUploadBlobFunction · 0.90
isSupportedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected