Use path.extname for some extension checks

This commit is contained in:
Michael B. Gale
2025-09-30 11:55:04 +01:00
parent 93711d3d89
commit ad086e4d90
10 changed files with 1584 additions and 1574 deletions
+1 -1
View File
@@ -334,7 +334,7 @@ test("resolveQuerySuiteAlias", (t) => {
for (const suite of defaultSuites) {
const resolved = resolveQuerySuiteAlias(KnownLanguage.go, suite);
t.assert(
resolved.endsWith(".qls"),
path.extname(resolved) === ".qls",
"Resolved default suite doesn't end in .qls",
);
t.assert(
+1 -1
View File
@@ -59,7 +59,7 @@ export async function uploadCombinedSarifArtifacts(
for (const outputDir of outputDirs) {
const sarifFiles = fs
.readdirSync(path.resolve(baseTempDir, outputDir))
.filter((f) => f.endsWith(".sarif"));
.filter((f) => path.extname(f) === ".sarif");
for (const sarifFile of sarifFiles) {
toUpload.push(path.resolve(baseTempDir, outputDir, sarifFile));
+3 -2
View File
@@ -480,8 +480,9 @@ export async function getGroupedSarifFilePaths(
const results = {};
if (stats.isDirectory()) {
let sarifFiles = findSarifFilesInDir(sarifPath, (name) =>
name.endsWith(".sarif"),
let sarifFiles = findSarifFilesInDir(
sarifPath,
(name) => path.extname(name) === ".sarif",
);
logger.debug(
`Found the following .sarif files in ${sarifPath}: ${sarifFiles.join(", ")}`,