@schmock/cli 2.0.3 → 2.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/dist/bin.js +33 -5
- package/dist/index.js +33 -5
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -23820,6 +23820,26 @@ function extractPathname(url) {
|
|
|
23820
23820
|
}
|
|
23821
23821
|
return urlWithoutQuery;
|
|
23822
23822
|
}
|
|
23823
|
+
function extractOrigin(url) {
|
|
23824
|
+
if (!url.includes("://"))
|
|
23825
|
+
return null;
|
|
23826
|
+
try {
|
|
23827
|
+
return new URL(url).origin;
|
|
23828
|
+
} catch {
|
|
23829
|
+
return null;
|
|
23830
|
+
}
|
|
23831
|
+
}
|
|
23832
|
+
function parseBaseUrl(baseUrl) {
|
|
23833
|
+
if (baseUrl.includes("://")) {
|
|
23834
|
+
try {
|
|
23835
|
+
const parsed = new URL(baseUrl);
|
|
23836
|
+
const rawPath = parsed.pathname;
|
|
23837
|
+
const path = rawPath === "/" ? "" : rawPath.replace(/\/$/, "");
|
|
23838
|
+
return { origin: parsed.origin, path };
|
|
23839
|
+
} catch {}
|
|
23840
|
+
}
|
|
23841
|
+
return { origin: null, path: baseUrl.replace(/\/$/, "") };
|
|
23842
|
+
}
|
|
23823
23843
|
function extractQuery(url) {
|
|
23824
23844
|
const queryStart = url.indexOf("?");
|
|
23825
23845
|
if (queryStart === -1)
|
|
@@ -23896,10 +23916,18 @@ function createFetchInterceptor(handle, options = {}) {
|
|
|
23896
23916
|
const urlString = input instanceof Request ? input.url : input instanceof URL ? input.href : input;
|
|
23897
23917
|
const path = extractPathname(urlString);
|
|
23898
23918
|
if (baseUrl) {
|
|
23899
|
-
const
|
|
23900
|
-
|
|
23901
|
-
|
|
23902
|
-
|
|
23919
|
+
const { origin: baseOrigin, path: basePath } = parseBaseUrl(baseUrl);
|
|
23920
|
+
if (baseOrigin) {
|
|
23921
|
+
const reqOrigin = extractOrigin(urlString);
|
|
23922
|
+
if (reqOrigin !== baseOrigin) {
|
|
23923
|
+
return originalFetch(input, init);
|
|
23924
|
+
}
|
|
23925
|
+
}
|
|
23926
|
+
if (basePath) {
|
|
23927
|
+
const isMatch = path === basePath || path.startsWith(`${basePath}/`);
|
|
23928
|
+
if (!isMatch) {
|
|
23929
|
+
return originalFetch(input, init);
|
|
23930
|
+
}
|
|
23903
23931
|
}
|
|
23904
23932
|
}
|
|
23905
23933
|
const method = input instanceof Request ? input.method : init?.method ?? "GET";
|
|
@@ -24579,7 +24607,7 @@ function schmock(config) {
|
|
|
24579
24607
|
return callableInstance;
|
|
24580
24608
|
}
|
|
24581
24609
|
// ../openapi/package.json
|
|
24582
|
-
var version = "2.0
|
|
24610
|
+
var version = "2.1.0";
|
|
24583
24611
|
|
|
24584
24612
|
// ../openapi/src/utils.ts
|
|
24585
24613
|
function isRecord(value) {
|
package/dist/index.js
CHANGED
|
@@ -23819,6 +23819,26 @@ function extractPathname(url) {
|
|
|
23819
23819
|
}
|
|
23820
23820
|
return urlWithoutQuery;
|
|
23821
23821
|
}
|
|
23822
|
+
function extractOrigin(url) {
|
|
23823
|
+
if (!url.includes("://"))
|
|
23824
|
+
return null;
|
|
23825
|
+
try {
|
|
23826
|
+
return new URL(url).origin;
|
|
23827
|
+
} catch {
|
|
23828
|
+
return null;
|
|
23829
|
+
}
|
|
23830
|
+
}
|
|
23831
|
+
function parseBaseUrl(baseUrl) {
|
|
23832
|
+
if (baseUrl.includes("://")) {
|
|
23833
|
+
try {
|
|
23834
|
+
const parsed = new URL(baseUrl);
|
|
23835
|
+
const rawPath = parsed.pathname;
|
|
23836
|
+
const path = rawPath === "/" ? "" : rawPath.replace(/\/$/, "");
|
|
23837
|
+
return { origin: parsed.origin, path };
|
|
23838
|
+
} catch {}
|
|
23839
|
+
}
|
|
23840
|
+
return { origin: null, path: baseUrl.replace(/\/$/, "") };
|
|
23841
|
+
}
|
|
23822
23842
|
function extractQuery(url) {
|
|
23823
23843
|
const queryStart = url.indexOf("?");
|
|
23824
23844
|
if (queryStart === -1)
|
|
@@ -23895,10 +23915,18 @@ function createFetchInterceptor(handle, options = {}) {
|
|
|
23895
23915
|
const urlString = input instanceof Request ? input.url : input instanceof URL ? input.href : input;
|
|
23896
23916
|
const path = extractPathname(urlString);
|
|
23897
23917
|
if (baseUrl) {
|
|
23898
|
-
const
|
|
23899
|
-
|
|
23900
|
-
|
|
23901
|
-
|
|
23918
|
+
const { origin: baseOrigin, path: basePath } = parseBaseUrl(baseUrl);
|
|
23919
|
+
if (baseOrigin) {
|
|
23920
|
+
const reqOrigin = extractOrigin(urlString);
|
|
23921
|
+
if (reqOrigin !== baseOrigin) {
|
|
23922
|
+
return originalFetch(input, init);
|
|
23923
|
+
}
|
|
23924
|
+
}
|
|
23925
|
+
if (basePath) {
|
|
23926
|
+
const isMatch = path === basePath || path.startsWith(`${basePath}/`);
|
|
23927
|
+
if (!isMatch) {
|
|
23928
|
+
return originalFetch(input, init);
|
|
23929
|
+
}
|
|
23902
23930
|
}
|
|
23903
23931
|
}
|
|
23904
23932
|
const method = input instanceof Request ? input.method : init?.method ?? "GET";
|
|
@@ -24578,7 +24606,7 @@ function schmock(config) {
|
|
|
24578
24606
|
return callableInstance;
|
|
24579
24607
|
}
|
|
24580
24608
|
// ../openapi/package.json
|
|
24581
|
-
var version = "2.0
|
|
24609
|
+
var version = "2.1.0";
|
|
24582
24610
|
|
|
24583
24611
|
// ../openapi/src/utils.ts
|
|
24584
24612
|
function isRecord(value) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schmock/cli",
|
|
3
3
|
"description": "CLI for running Schmock mock servers from OpenAPI specs",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@schmock/core": "^2.0
|
|
36
|
-
"@schmock/openapi": "^2.0
|
|
35
|
+
"@schmock/core": "^2.1.0",
|
|
36
|
+
"@schmock/openapi": "^2.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@amiceli/vitest-cucumber": "^6.5.0",
|