@apidevtools/json-schema-ref-parser 13.0.2 → 13.0.4

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.
@@ -90,8 +90,19 @@ function resolve(from, to) {
90
90
  * @returns
91
91
  */
92
92
  function cwd() {
93
- if (typeof window !== "undefined" && window.location) {
94
- return location.href;
93
+ if (typeof window !== "undefined" && window.location && window.location.href) {
94
+ const href = window.location.href;
95
+ if (!href || !href.startsWith("http")) {
96
+ // try parsing as url, and if it fails, return root url /
97
+ try {
98
+ new URL(href);
99
+ return href;
100
+ }
101
+ catch {
102
+ return "/";
103
+ }
104
+ }
105
+ return href;
95
106
  }
96
107
  if (typeof process !== "undefined" && process.cwd) {
97
108
  const path = process.cwd();
package/lib/util/url.ts CHANGED
@@ -44,8 +44,18 @@ export function resolve(from: string, to: string) {
44
44
  * @returns
45
45
  */
46
46
  export function cwd() {
47
- if (typeof window !== "undefined" && window.location) {
48
- return location.href;
47
+ if (typeof window !== "undefined" && window.location && window.location.href) {
48
+ const href = window.location.href;
49
+ if (!href || !href.startsWith("http")) {
50
+ // try parsing as url, and if it fails, return root url /
51
+ try {
52
+ new URL(href);
53
+ return href;
54
+ } catch {
55
+ return "/";
56
+ }
57
+ }
58
+ return href;
49
59
  }
50
60
 
51
61
  if (typeof process !== "undefined" && process.cwd) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apidevtools/json-schema-ref-parser",
3
- "version": "13.0.2",
3
+ "version": "13.0.4",
4
4
  "description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",
5
5
  "scripts": {
6
6
  "prepublishOnly": "yarn build",
@@ -74,7 +74,7 @@
74
74
  "@types/node": "^22",
75
75
  "@typescript-eslint/eslint-plugin": "^8.33.1",
76
76
  "@typescript-eslint/parser": "^8.33.1",
77
- "@vitest/coverage-v8": "^3.2.1",
77
+ "@vitest/coverage-v8": "^3.2.2",
78
78
  "cross-env": "^7.0.3",
79
79
  "eslint": "^9.28.0",
80
80
  "eslint-config-prettier": "^10.1.5",
@@ -89,7 +89,7 @@
89
89
  "rimraf": "^6.0.1",
90
90
  "typescript": "^5.8.3",
91
91
  "typescript-eslint": "^8.33.1",
92
- "vitest": "^3.2.1"
92
+ "vitest": "^3.2.2"
93
93
  },
94
94
  "dependencies": {
95
95
  "@types/json-schema": "^7.0.15",