(url: string)
| 92 | } |
| 93 | |
| 94 | export 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 | |
| 111 | export function isSupported(url: string): boolean { |
| 112 | const ext = getUrlExtension(url); |
no outgoing calls
no test coverage detected