UNPKG

astro

Version:

Astro is a modern site builder with web best practices, performance, and DX front-of-mind.

22 lines (21 loc) 591 B
import { extname } from "node:path"; import { AstroError, AstroErrorData } from "../../../core/errors/index.js"; import { isFontType } from "../utils.js"; class NodeFontTypeExtractor { extract(url) { const extension = extname(url).slice(1); if (!isFontType(extension)) { throw new AstroError( { ...AstroErrorData.CannotExtractFontType, message: AstroErrorData.CannotExtractFontType.message(url) }, { cause: `Unexpected extension, got "${extension}"` } ); } return extension; } } export { NodeFontTypeExtractor };