@scalar/import 0.1.0 → 0.1.2
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 +13 -0
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +20 -5
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
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":"AAEA;;;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,CAmHnD"}
|
package/dist/resolve.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { makeUrlAbsolute } from '@scalar/oas-utils/helpers';
|
|
2
1
|
import { parse } from 'yaml';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -42,8 +41,6 @@ async function resolve(value, options) {
|
|
|
42
41
|
}
|
|
43
42
|
if (result.ok) {
|
|
44
43
|
const content = await result.text();
|
|
45
|
-
const forwardedHost = result.headers.get('X-Forwarded-Host');
|
|
46
|
-
console.log('ASAS', forwardedHost);
|
|
47
44
|
// Check if content is directly JSON/YAML
|
|
48
45
|
try {
|
|
49
46
|
// Try parsing as JSON
|
|
@@ -91,8 +88,7 @@ async function resolve(value, options) {
|
|
|
91
88
|
}
|
|
92
89
|
// Relative or absolute URL
|
|
93
90
|
if (urlOrPathOrDocument) {
|
|
94
|
-
|
|
95
|
-
return makeUrlAbsolute(urlOrPathOrDocument, forwardedHost || value);
|
|
91
|
+
return makeRelativeUrlsAbsolute(value, urlOrPathOrDocument);
|
|
96
92
|
}
|
|
97
93
|
// Check for embedded OpenAPI document
|
|
98
94
|
const embeddedSpec = parseEmbeddedOpenApi(content);
|
|
@@ -191,6 +187,25 @@ function parseScriptContent(html) {
|
|
|
191
187
|
}
|
|
192
188
|
return undefined;
|
|
193
189
|
}
|
|
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
|
+
}
|
|
194
209
|
/**
|
|
195
210
|
* Parse embedded OpenAPI document from HTML
|
|
196
211
|
*/
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"postman",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.1.
|
|
19
|
+
"version": "0.1.2",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -36,11 +36,10 @@
|
|
|
36
36
|
"module": "dist/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"yaml": "^2.4.5",
|
|
39
|
-
"@scalar/openapi-parser": "0.8.
|
|
40
|
-
"@scalar/oas-utils": "0.2.72"
|
|
39
|
+
"@scalar/openapi-parser": "0.8.10"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
|
-
"vite": "^5.4.
|
|
42
|
+
"vite": "^5.4.10",
|
|
44
43
|
"@scalar/build-tooling": "0.1.12"
|
|
45
44
|
},
|
|
46
45
|
"scripts": {
|