From fc44e2a561b6793db5d8c6b00482e9a12b176725 Mon Sep 17 00:00:00 2001 From: Sondre Aasemoen Date: Thu, 29 Dec 2022 12:46:48 +0100 Subject: [PATCH] Use extname to get file extension --- src/compress.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compress.ts b/src/compress.ts index bb1916b..f85d9a5 100644 --- a/src/compress.ts +++ b/src/compress.ts @@ -1,6 +1,6 @@ import { createReadStream, createWriteStream } from "node:fs"; import { readdir } from "node:fs/promises"; -import { resolve } from "node:path"; +import { extname, resolve } from "node:path"; import { hrtime } from "node:process"; import { promises as stream } from "node:stream"; import { createBrotliCompress, createGzip } from "node:zlib"; @@ -20,8 +20,8 @@ async function* walkDir(dir: string): AsyncGenerator { } const filterFile = (file: string): boolean => { - return [".css", ".js", ".html", ".xml", ".cjs", ".mjs", ".svg", ".txt"].some((ext) => - file.endsWith(ext), + return [".css", ".js", ".html", ".xml", ".cjs", ".mjs", ".svg", ".txt"].some( + (ext) => extname(file) == ext, ); };