I encountered an issue running the meta-schema tests on a Windows environment. Running npm test fails immediately on all 7 test cases with Error: Invalid IRI-reference.
Root Cause
The path resolution in specs/meta/test-suite/meta-schema.test.js resolves the meta-schema path using a string template:
`${import.meta.dirname}/../meta.schema.json`
On Windows, this resolves with backslashes (e.g., D:\path\to\specs\meta\test-suite/../meta.schema.json). Because the internally used @hyperjump/uri library strictly validates references against RFC 3986 (where backslashes are illegal URI characters), the parser throws an exception and crashes the test run.
Steps to Reproduce
- Clone the repository on Windows.
- Run
npm install and npm test.
- The test execution fails with the following traceback:
Error: Invalid IRI-reference: D:\VS Code Projects\OSS\json-schema-spec\specs\meta\test-suite/../meta.schema.json
❯ Object.parseReference node_modules/@hyperjump/uri/lib/index.js:225:11
❯ node_modules/@hyperjump/uri/lib/index.js:83:78
❯ getSchema node_modules/@hyperjump/json-schema/lib/schema.js:33:24
Screenshot:
Proposed Solution
To ensure cross-platform compatibility, we can resolve the file path as a standard file URL:
const metaSchemaUrl = new URL("../meta.schema.json", import.meta.url).href;
I have verified this fix locally on Windows and all tests pass.
I encountered an issue running the meta-schema tests on a Windows environment. Running
npm testfails immediately on all 7 test cases withError: Invalid IRI-reference.Root Cause
The path resolution in
specs/meta/test-suite/meta-schema.test.jsresolves the meta-schema path using a string template:`${import.meta.dirname}/../meta.schema.json`On Windows, this resolves with backslashes (e.g.,
D:\path\to\specs\meta\test-suite/../meta.schema.json). Because the internally used@hyperjump/urilibrary strictly validates references against RFC 3986 (where backslashes are illegal URI characters), the parser throws an exception and crashes the test run.Steps to Reproduce
npm installandnpm test.Screenshot:
Proposed Solution
To ensure cross-platform compatibility, we can resolve the file path as a standard file URL:
I have verified this fix locally on Windows and all tests pass.