Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: codex <[email protected]>
30 lines
928 B
TypeScript
30 lines
928 B
TypeScript
export const WORKSPACE_BROWSER_PREVIEW_EXTENSIONS = [".htm", ".html", ".pdf"] as const;
|
|
|
|
export const WORKSPACE_IMAGE_PREVIEW_EXTENSIONS = [
|
|
".avif",
|
|
".gif",
|
|
".ico",
|
|
".jpeg",
|
|
".jpg",
|
|
".png",
|
|
".svg",
|
|
".webp",
|
|
] as const;
|
|
|
|
function hasPreviewExtension(path: string, extensions: ReadonlyArray<string>): boolean {
|
|
const pathWithoutQuery = path.split(/[?#]/, 1)[0]?.toLowerCase() ?? "";
|
|
return extensions.some((extension) => pathWithoutQuery.endsWith(extension));
|
|
}
|
|
|
|
export function isWorkspaceBrowserPreviewPath(path: string): boolean {
|
|
return hasPreviewExtension(path, WORKSPACE_BROWSER_PREVIEW_EXTENSIONS);
|
|
}
|
|
|
|
export function isWorkspaceImagePreviewPath(path: string): boolean {
|
|
return hasPreviewExtension(path, WORKSPACE_IMAGE_PREVIEW_EXTENSIONS);
|
|
}
|
|
|
|
export function isWorkspacePreviewEntryPath(path: string): boolean {
|
|
return isWorkspaceBrowserPreviewPath(path) || isWorkspaceImagePreviewPath(path);
|
|
}
|