All checks were successful
Bump deps (only minor versions) / ci (push) Successful in 16s
22 lines
No EOL
514 B
TypeScript
22 lines
No EOL
514 B
TypeScript
import formats from '$lib/common/supportedFormats.json';
|
|
|
|
const formatMime = new Map(Object.entries(formats))
|
|
export const isURLValid = (url: string) => {
|
|
try {
|
|
new URL(url)
|
|
} catch {
|
|
return false
|
|
}
|
|
|
|
return true;
|
|
}
|
|
export const mimeTypeMap = formatMime;
|
|
export const contentTypeFromFormat = (format: string): string => {
|
|
const toReturn: string | undefined = formatMime.get(format)
|
|
|
|
if (!toReturn) {
|
|
throw new Error("Unsupported format")
|
|
}
|
|
|
|
return toReturn;
|
|
} |