@scalar/import 0.0.5 → 0.1.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 +20 -0
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +6 -21
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @scalar/import
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c98a99c: feat: use X-Forwarded-Host header (if available)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [4bcaa75]
|
|
12
|
+
- Updated dependencies [9eb6650]
|
|
13
|
+
- Updated dependencies [c98a99c]
|
|
14
|
+
- @scalar/oas-utils@0.2.72
|
|
15
|
+
|
|
16
|
+
## 0.0.6
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- a40999d: chore: added type safety rule noUncheckedIndexedAccess
|
|
21
|
+
- @scalar/openapi-parser@0.8.9
|
|
22
|
+
|
|
3
23
|
## 0.0.5
|
|
4
24
|
|
|
5
25
|
### 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,CAuHnD"}
|
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,8 @@ 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');
|
|
46
|
+
console.log('ASAS', forwardedHost);
|
|
44
47
|
// Check if content is directly JSON/YAML
|
|
45
48
|
try {
|
|
46
49
|
// Try parsing as JSON
|
|
@@ -88,7 +91,8 @@ async function resolve(value, options) {
|
|
|
88
91
|
}
|
|
89
92
|
// Relative or absolute URL
|
|
90
93
|
if (urlOrPathOrDocument) {
|
|
91
|
-
|
|
94
|
+
console.log('make absolute', forwardedHost, urlOrPathOrDocument);
|
|
95
|
+
return makeUrlAbsolute(urlOrPathOrDocument, forwardedHost || value);
|
|
92
96
|
}
|
|
93
97
|
// Check for embedded OpenAPI document
|
|
94
98
|
const embeddedSpec = parseEmbeddedOpenApi(content);
|
|
@@ -187,31 +191,12 @@ function parseScriptContent(html) {
|
|
|
187
191
|
}
|
|
188
192
|
return undefined;
|
|
189
193
|
}
|
|
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
194
|
/**
|
|
210
195
|
* Parse embedded OpenAPI document from HTML
|
|
211
196
|
*/
|
|
212
197
|
function parseEmbeddedOpenApi(html) {
|
|
213
198
|
const match = html.match(/<script[^>]*data-configuration=['"]([^'"]+)['"][^>]*>(.*?)<\/script>/s);
|
|
214
|
-
if (!match)
|
|
199
|
+
if (!match?.[1])
|
|
215
200
|
return undefined;
|
|
216
201
|
try {
|
|
217
202
|
const configString = decodeHtmlEntities(match[1]);
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"postman",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.0
|
|
19
|
+
"version": "0.1.0",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -36,11 +36,12 @@
|
|
|
36
36
|
"module": "dist/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"yaml": "^2.4.5",
|
|
39
|
-
"@scalar/openapi-parser": "0.8.9"
|
|
39
|
+
"@scalar/openapi-parser": "0.8.9",
|
|
40
|
+
"@scalar/oas-utils": "0.2.72"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"vite": "^5.4.9",
|
|
43
|
-
"@scalar/build-tooling": "0.1.
|
|
44
|
+
"@scalar/build-tooling": "0.1.12"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"build": "scalar-build-rollup",
|