@apidevtools/json-schema-ref-parser 14.2.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +0 -4
  2. package/dist/lib/bundle.d.ts +3 -3
  3. package/dist/lib/bundle.js +16 -54
  4. package/dist/lib/dereference.d.ts +1 -2
  5. package/dist/lib/dereference.js +12 -50
  6. package/dist/lib/index.js +42 -95
  7. package/dist/lib/normalize-args.d.ts +1 -1
  8. package/dist/lib/normalize-args.js +4 -7
  9. package/dist/lib/options.d.ts +6 -0
  10. package/dist/lib/options.js +16 -23
  11. package/dist/lib/parse.js +11 -46
  12. package/dist/lib/parsers/binary.js +1 -3
  13. package/dist/lib/parsers/json.js +4 -6
  14. package/dist/lib/parsers/text.js +3 -5
  15. package/dist/lib/parsers/yaml.js +12 -11
  16. package/dist/lib/pointer.d.ts +3 -2
  17. package/dist/lib/pointer.js +18 -63
  18. package/dist/lib/ref.d.ts +5 -3
  19. package/dist/lib/ref.js +60 -52
  20. package/dist/lib/refs.d.ts +1 -1
  21. package/dist/lib/refs.js +7 -46
  22. package/dist/lib/resolve-external.js +10 -48
  23. package/dist/lib/resolvers/file.js +7 -45
  24. package/dist/lib/resolvers/http.js +5 -40
  25. package/dist/lib/types/index.d.ts +1 -1
  26. package/dist/lib/types/index.js +1 -2
  27. package/dist/lib/util/convert-path-to-posix.js +3 -9
  28. package/dist/lib/util/errors.d.ts +1 -1
  29. package/dist/lib/util/errors.js +17 -33
  30. package/dist/lib/util/is-windows.js +1 -5
  31. package/dist/lib/util/maybe.js +4 -10
  32. package/dist/lib/util/next.js +1 -3
  33. package/dist/lib/util/plugins.js +4 -10
  34. package/dist/lib/util/url.d.ts +1 -1
  35. package/dist/lib/util/url.js +40 -88
  36. package/lib/bundle.ts +12 -9
  37. package/lib/dereference.ts +3 -4
  38. package/lib/normalize-args.ts +1 -1
  39. package/lib/options.ts +8 -0
  40. package/lib/parsers/yaml.ts +6 -1
  41. package/lib/pointer.ts +19 -20
  42. package/lib/ref.ts +55 -5
  43. package/lib/refs.ts +2 -2
  44. package/lib/types/index.ts +1 -1
  45. package/lib/util/errors.ts +2 -2
  46. package/lib/util/url.ts +13 -7
  47. package/package.json +21 -20
package/lib/util/url.ts CHANGED
@@ -1,4 +1,4 @@
1
- import convertPathToPosix from "./convert-path-to-posix";
1
+ import convertPathToPosix from "./convert-path-to-posix.js";
2
2
  import path, { win32 } from "path";
3
3
 
4
4
  const forwardSlashPattern = /\//g;
@@ -7,7 +7,7 @@ const jsonPointerSlash = /~1/g;
7
7
  const jsonPointerTilde = /~0/g;
8
8
 
9
9
  import { join } from "path";
10
- import { isWindows } from "./is-windows";
10
+ import { isWindows } from "./is-windows.js";
11
11
 
12
12
  // RegExp patterns to URL-encode special characters in local filesystem paths
13
13
  const urlEncodePatterns = [
@@ -33,9 +33,15 @@ export function resolve(from: string, to: string) {
33
33
  if (resolvedUrl.hostname === "aaa.nonexistanturl.com") {
34
34
  // `from` is a relative URL.
35
35
  const { pathname, search, hash } = resolvedUrl;
36
- return pathname + search + hash + endSpaces;
36
+ return pathname + search + decodeURIComponent(hash) + endSpaces;
37
37
  }
38
- return resolvedUrl.toString() + endSpaces;
38
+ const resolved = resolvedUrl.toString() + endSpaces;
39
+ // if there is a #, we want to split on the first one only, and decode the part after
40
+ if (resolved.includes("#")) {
41
+ const [base, hash] = resolved.split("#", 2);
42
+ return base + "#" + decodeURIComponent(hash || "");
43
+ }
44
+ return resolved;
39
45
  }
40
46
 
41
47
  /**
@@ -467,7 +473,7 @@ export function toFileSystemPath(path: string | undefined, keepFileProtocol?: bo
467
473
  * @param pointer
468
474
  * @returns
469
475
  */
470
- export function safePointerToPath(pointer: any) {
476
+ export function safePointerToPath(pointer: string) {
471
477
  if (pointer.length <= 1 || pointer[0] !== "#" || pointer[1] !== "/") {
472
478
  return [];
473
479
  }
@@ -475,8 +481,8 @@ export function safePointerToPath(pointer: any) {
475
481
  return pointer
476
482
  .slice(2)
477
483
  .split("/")
478
- .map((value: any) => {
479
- return decodeURIComponent(value).replace(jsonPointerSlash, "/").replace(jsonPointerTilde, "~");
484
+ .map((value: string) => {
485
+ return value.replace(jsonPointerSlash, "/").replace(jsonPointerTilde, "~");
480
486
  });
481
487
  }
482
488
 
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@apidevtools/json-schema-ref-parser",
3
- "version": "14.2.0",
3
+ "version": "15.0.0",
4
4
  "description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
5
+ "type": "module",
6
+ "types": "dist/lib/index.d.ts",
7
+ "module": "dist/lib/index.js",
5
8
  "scripts": {
6
9
  "prepublishOnly": "yarn build",
7
10
  "lint": "eslint lib",
@@ -9,6 +12,7 @@
9
12
  "typecheck": "tsc --noEmit",
10
13
  "prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"",
11
14
  "test": "vitest --coverage",
15
+ "test:specific": "vitest invalid",
12
16
  "test:node": "yarn test",
13
17
  "test:browser": "cross-env BROWSER=\"true\" yarn test",
14
18
  "test:update": "vitest -u",
@@ -53,14 +57,11 @@
53
57
  "url": "https://github.com/APIDevTools/json-schema-ref-parser.git"
54
58
  },
55
59
  "license": "MIT",
56
- "funding": "https://github.com/sponsors/philsturgeon",
57
- "types": "dist/lib/index.d.ts",
58
- "main": "dist/lib/index.js",
59
60
  "browser": {
60
61
  "fs": false
61
62
  },
62
63
  "engines": {
63
- "node": ">= 20"
64
+ "node": ">=20"
64
65
  },
65
66
  "files": [
66
67
  "lib",
@@ -73,29 +74,29 @@
73
74
  "js-yaml": "^4.1.0"
74
75
  },
75
76
  "devDependencies": {
76
- "@eslint/compat": "^1.3.2",
77
- "@eslint/js": "^9.33.0",
77
+ "@eslint/compat": "^1.4.1",
78
+ "@eslint/js": "^9.39.1",
78
79
  "@types/eslint": "^9.6.1",
79
80
  "@types/js-yaml": "^4.0.9",
80
81
  "@types/json-schema": "^7.0.15",
81
82
  "@types/node": "^24",
82
- "@typescript-eslint/eslint-plugin": "^8.39.1",
83
- "@typescript-eslint/parser": "^8.39.1",
84
- "@vitest/coverage-v8": "^3.2.4",
85
- "cross-env": "^10.0.0",
86
- "eslint": "^9.33.0",
83
+ "@typescript-eslint/eslint-plugin": "^8.46.4",
84
+ "@typescript-eslint/parser": "^8.46.4",
85
+ "@vitest/coverage-v8": "^4.0.8",
86
+ "cross-env": "^10.1.0",
87
+ "eslint": "^9.39.1",
87
88
  "eslint-config-prettier": "^10.1.8",
88
89
  "eslint-plugin-import": "^2.32.0",
89
90
  "eslint-plugin-prettier": "^5.5.4",
90
91
  "eslint-plugin-promise": "^7.2.1",
91
- "eslint-plugin-unused-imports": "^4.2.0",
92
- "globals": "^16.3.0",
93
- "jsdom": "^26.1.0",
92
+ "eslint-plugin-unused-imports": "^4.3.0",
93
+ "globals": "^16.5.0",
94
+ "jsdom": "^27.1.0",
94
95
  "prettier": "^3.6.2",
95
- "rimraf": "^6.0.1",
96
- "typescript": "^5.9.2",
97
- "typescript-eslint": "^8.39.1",
98
- "vitest": "^3.2.4"
96
+ "rimraf": "^6.1.0",
97
+ "typescript": "^5.9.3",
98
+ "typescript-eslint": "^8.46.4",
99
+ "vitest": "^4.0.8"
99
100
  },
100
101
  "release": {
101
102
  "branches": [
@@ -108,5 +109,5 @@
108
109
  "@semantic-release/github"
109
110
  ]
110
111
  },
111
- "packageManager": "yarn@4.9.2"
112
+ "packageManager": "yarn@4.11.0"
112
113
  }