@scalar/oas-utils 0.2.81 → 0.2.82

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.82
4
+
5
+ ### Patch Changes
6
+
7
+ - 6389557: feat: allow to pass a base URL to makeUrlAbsolute
8
+ - Updated dependencies [baaad1c]
9
+ - Updated dependencies [c984ac8]
10
+ - @scalar/types@0.0.22
11
+ - @scalar/themes@0.9.53
12
+
3
13
  ## 0.2.81
4
14
 
5
15
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Pass an URL or a relative URL and get an absolute URL
3
3
  */
4
- export declare const makeUrlAbsolute: (url?: string) => string | undefined;
4
+ export declare const makeUrlAbsolute: (url?: string, baseUrl?: string) => string | undefined;
5
5
  //# sourceMappingURL=makeUrlAbsolute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeUrlAbsolute.d.ts","sourceRoot":"","sources":["../../src/helpers/makeUrlAbsolute.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe,SAAU,MAAM,uBAqB3C,CAAA"}
1
+ {"version":3,"file":"makeUrlAbsolute.d.ts","sourceRoot":"","sources":["../../src/helpers/makeUrlAbsolute.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe,SAAU,MAAM,YAAY,MAAM,uBAsB7D,CAAA"}
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * Pass an URL or a relative URL and get an absolute URL
3
3
  */
4
- const makeUrlAbsolute = (url) => {
4
+ const makeUrlAbsolute = (url, baseUrl) => {
5
5
  if (!url ||
6
6
  url.startsWith('http://') ||
7
7
  url.startsWith('https://') ||
8
- typeof window === 'undefined')
8
+ (typeof window === 'undefined' && !baseUrl)) {
9
9
  return url;
10
- const baseUrl = window.location.href;
10
+ }
11
+ const base = baseUrl || window.location.href;
11
12
  // Remove any query parameters or hash from the base URL
12
- const cleanBaseUrl = baseUrl.split('?')[0]?.split('#')[0];
13
+ const cleanBaseUrl = base.split('?')[0]?.split('#')[0];
13
14
  // For base URLs with a path component, we want to remove the last path segment
14
15
  // if it doesn't end with a slash
15
16
  const normalizedBaseUrl = cleanBaseUrl?.endsWith('/')
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.81",
19
+ "version": "0.2.82",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -113,8 +113,8 @@
113
113
  "zod": "^3.23.8",
114
114
  "@scalar/object-utils": "1.1.12",
115
115
  "@scalar/openapi-types": "0.1.5",
116
- "@scalar/themes": "0.9.52",
117
- "@scalar/types": "0.0.21"
116
+ "@scalar/themes": "0.9.53",
117
+ "@scalar/types": "0.0.22"
118
118
  },
119
119
  "devDependencies": {
120
120
  "type-fest": "^4.20.0",
@@ -122,8 +122,8 @@
122
122
  "vitest": "^1.6.0",
123
123
  "zod-to-ts": "github:amritk/zod-to-ts#build",
124
124
  "@scalar/build-tooling": "0.1.12",
125
- "@scalar/openapi-parser": "0.8.10",
126
- "@scalar/openapi-types": "0.1.5"
125
+ "@scalar/openapi-types": "0.1.5",
126
+ "@scalar/openapi-parser": "0.8.10"
127
127
  },
128
128
  "scripts": {
129
129
  "build": "scalar-build-rollup",