The last extension alone cannot identify every compound file format. Treat extension parsing as a filename convention rather than content detection.
Worked example
import { posix as path } from "node:path";
console.log(path.extname(".env.local"));Result
.localImplementation notes
An extension check is useful for choosing a processing path, but the parser must still validate the actual file contents.
Try it yourself
Compare an archive ending in .tar.gz, a hidden file and a directory name.
Open the Node.js example →Editorial date December 24, 2025 · Published December 6, 2026