Skip to content

Commit

Permalink
fix(hsts): rework file path resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
argl committed Jul 24, 2024
1 parent 0ea5178 commit ce1dc5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/analyzer/hsts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import fs from "fs";
import path from "path";
import path from "node:path";
import { fileURLToPath } from "node:url";

const dirname = path.dirname(fileURLToPath(import.meta.url));

/**
* @type {import("../types.js").Hsts | null}
Expand All @@ -11,10 +14,15 @@ let hstsMap = null;
*/
export function hsts() {
if (!hstsMap) {
const filePath = path.join(
dirname,
"..",
"..",
"conf",
"hsts-preload.json"
);
hstsMap = new Map(
Object.entries(
JSON.parse(fs.readFileSync(path.resolve(import.meta.dirname, "../../conf/hsts-preload.json"), "utf8"))
)
Object.entries(JSON.parse(fs.readFileSync(filePath, "utf8")))
);
}
return hstsMap;
Expand Down
1 change: 0 additions & 1 deletion src/database/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export async function insertTestResults(pool, siteId, scanId, scanResult) {
const scoreModifier = t.scoreModifier;
delete t.scoreModifier;
delete t.scoreDescription;
delete t.name;

return [
siteId,
Expand Down

0 comments on commit ce1dc5d

Please sign in to comment.