12 行
464 B
TypeScript
12 行
464 B
TypeScript
export function isStorageUri(value: string): boolean {
|
|
return /^storage:\/\/[a-z0-9_-]+(?:\/[^?#]*)?$/i.test(value.trim())
|
|
}
|
|
|
|
export function storageFilename(value: string): string {
|
|
const normalized = value.trim().split(/[?#]/, 1)[0].replace(/\/+$/, "")
|
|
return normalized.split("/").pop() ?? ""
|
|
}
|
|
|
|
export function isSupportedImageStorageUri(value: string): boolean {
|
|
return isStorageUri(value) && /\.(png|jpe?g|gif|webp)$/i.test(storageFilename(value))
|
|
}
|