@scalar/import 0.1.1 → 0.2.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.
- package/CHANGELOG.md +18 -0
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +3 -20
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @scalar/import
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6389557: feat: use X-Forwarded-Host header (if available)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [6389557]
|
|
12
|
+
- @scalar/oas-utils@0.2.82
|
|
13
|
+
|
|
14
|
+
## 0.1.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [98e9cb2]
|
|
19
|
+
- @scalar/openapi-parser@0.8.10
|
|
20
|
+
|
|
3
21
|
## 0.1.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/resolve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EACrB,OAAO,CAAC,EAAE;IACR;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC3C,GACA,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,CAoHnD"}
|
package/dist/resolve.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { makeUrlAbsolute } from '@scalar/oas-utils/helpers';
|
|
1
2
|
import { parse } from 'yaml';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -41,6 +42,7 @@ async function resolve(value, options) {
|
|
|
41
42
|
}
|
|
42
43
|
if (result.ok) {
|
|
43
44
|
const content = await result.text();
|
|
45
|
+
const forwardedHost = result.headers.get('X-Forwarded-Host');
|
|
44
46
|
// Check if content is directly JSON/YAML
|
|
45
47
|
try {
|
|
46
48
|
// Try parsing as JSON
|
|
@@ -88,7 +90,7 @@ async function resolve(value, options) {
|
|
|
88
90
|
}
|
|
89
91
|
// Relative or absolute URL
|
|
90
92
|
if (urlOrPathOrDocument) {
|
|
91
|
-
return
|
|
93
|
+
return makeUrlAbsolute(urlOrPathOrDocument, forwardedHost || value);
|
|
92
94
|
}
|
|
93
95
|
// Check for embedded OpenAPI document
|
|
94
96
|
const embeddedSpec = parseEmbeddedOpenApi(content);
|
|
@@ -187,25 +189,6 @@ function parseScriptContent(html) {
|
|
|
187
189
|
}
|
|
188
190
|
return undefined;
|
|
189
191
|
}
|
|
190
|
-
/**
|
|
191
|
-
* URLs can be relative, but we need absolute URLs eventually.
|
|
192
|
-
*/
|
|
193
|
-
function makeRelativeUrlsAbsolute(baseUrl, path) {
|
|
194
|
-
// Check whether the path is already absolute
|
|
195
|
-
if (path.startsWith('http://') || path.startsWith('https://')) {
|
|
196
|
-
return path;
|
|
197
|
-
}
|
|
198
|
-
// Combine the URL and the relative path
|
|
199
|
-
try {
|
|
200
|
-
const { href } = new URL(path, baseUrl);
|
|
201
|
-
return href;
|
|
202
|
-
}
|
|
203
|
-
catch (error) {
|
|
204
|
-
// Return original path if URL creation fails
|
|
205
|
-
console.error('[makeRelativeUrlsAbsolute] Error combining URLs:', error);
|
|
206
|
-
return path;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
192
|
/**
|
|
210
193
|
* Parse embedded OpenAPI document from HTML
|
|
211
194
|
*/
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"postman",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.2.0",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
"module": "dist/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"yaml": "^2.4.5",
|
|
39
|
-
"@scalar/
|
|
39
|
+
"@scalar/oas-utils": "0.2.82",
|
|
40
|
+
"@scalar/openapi-parser": "0.8.10"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"vite": "^5.4.
|
|
43
|
+
"vite": "^5.4.10",
|
|
43
44
|
"@scalar/build-tooling": "0.1.12"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|