From 0e3460475147fa3432129c6c3076f6894245c7b4 Mon Sep 17 00:00:00 2001 From: Hans Klunder Date: Tue, 12 Nov 2024 18:42:59 +0100 Subject: [PATCH] fix: removed dependency on "node:url" to aid in bundling --- CHANGELOG.md | 4 ++++ index.js | 5 ++--- test/check-versions.js | 1 - test/test-bundle-cli.js | 5 ++--- test/test-validate-cli.js | 5 ++--- test/test-validation-refs.js | 5 ++--- test/test-validation.js | 5 ++--- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dc9676..ee9fd26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] ### Changed + +## [v2.2.4] 12-11-2024 +### Changed + - fix: removed dependency on "node:url" to aid in bundling - updated dependencies - @biomejs/biome ^1.8.3 → ^1.9.4 diff --git a/index.js b/index.js index 00b07e8..c7968ca 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,5 @@ import { readFileSync } from "node:fs"; import { readFile } from "node:fs/promises"; -import { URL, fileURLToPath } from "node:url"; import Ajv04 from "ajv-draft-04"; import addFormats from "ajv-formats"; import Ajv2020 from "ajv/dist/2020.js"; @@ -14,8 +13,8 @@ const ajvVersions = { }; const inlinedRefs = "x-inlined-refs"; -function localFile(fileName) { - return fileURLToPath(new URL(fileName, import.meta.url)); +function localFile(file) { + return new URL(file, import.meta.url).pathname; } function importJSON(file) { diff --git a/test/check-versions.js b/test/check-versions.js index 30a86a8..847827b 100644 --- a/test/check-versions.js +++ b/test/check-versions.js @@ -3,7 +3,6 @@ import { createHash } from "node:crypto"; import { readFileSync } from "node:fs"; import { readdir } from "node:fs/promises"; import { test } from "node:test"; -import { URL } from "node:url"; import { Validator } from "../index.js"; import { Snapshot } from "./snapshot.js"; diff --git a/test/test-bundle-cli.js b/test/test-bundle-cli.js index 4341e38..b206641 100644 --- a/test/test-bundle-cli.js +++ b/test/test-bundle-cli.js @@ -2,11 +2,10 @@ import { strict as assert } from "node:assert/strict"; import { execSync } from "node:child_process"; import { readFileSync, unlinkSync } from "node:fs"; import { test } from "node:test"; -import { URL, fileURLToPath } from "node:url"; import { load } from "js-yaml"; -function localFile(fileName) { - return fileURLToPath(new URL(fileName, import.meta.url)); +function localFile(file) { + return new URL(file, import.meta.url).pathname; } function importJSON(file) { diff --git a/test/test-validate-cli.js b/test/test-validate-cli.js index ccc1570..5389d87 100644 --- a/test/test-validate-cli.js +++ b/test/test-validate-cli.js @@ -1,10 +1,9 @@ import { strict as assert } from "node:assert/strict"; import { execSync } from "node:child_process"; import { test } from "node:test"; -import { URL, fileURLToPath } from "node:url"; -function localFile(fileName) { - return fileURLToPath(new URL(fileName, import.meta.url)); +function localFile(file) { + return new URL(file, import.meta.url).pathname; } const cli = localFile("../bin/validate-api-cli.js"); diff --git a/test/test-validation-refs.js b/test/test-validation-refs.js index 1f5daf9..18a208a 100644 --- a/test/test-validation-refs.js +++ b/test/test-validation-refs.js @@ -1,10 +1,9 @@ import { strict as assert } from "node:assert/strict"; import { test } from "node:test"; -import { URL, fileURLToPath } from "node:url"; import { Validator } from "../index.js"; -function localFile(fileName) { - return fileURLToPath(new URL(fileName, import.meta.url)); +function localFile(file) { + return new URL(file, import.meta.url).pathname; } const invalidRefsSpec = localFile("./validation/invalid-refs.yaml"); diff --git a/test/test-validation.js b/test/test-validation.js index d20cb16..53713fe 100644 --- a/test/test-validation.js +++ b/test/test-validation.js @@ -2,11 +2,10 @@ import { strict as assert } from "node:assert/strict"; import { readFileSync } from "node:fs"; import { readFile } from "node:fs/promises"; import { test } from "node:test"; -import { URL, fileURLToPath } from "node:url"; import { Validator } from "../index.js"; -function localFile(fileName) { - return fileURLToPath(new URL(fileName, import.meta.url)); +function localFile(file) { + return new URL(file, import.meta.url).pathname; } function importJSON(file) {