@keq-request/url 5.0.0-alpha.7 → 5.0.0-alpha.9
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/.turbo/turbo-build.log +18 -0
- package/CHANGELOG.md +18 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +42 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +3 -4
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
> @keq-request/url@5.0.0-alpha.9 build /home/runner/work/keq/keq/packages/url
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.lib.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.0
|
|
8
|
+
[34mCLI[39m Using tsup config: /home/runner/work/keq/keq/packages/url/tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: esnext
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mCJS[39m Build start
|
|
12
|
+
[34mESM[39m Build start
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m2.14 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m2.66 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 32ms
|
|
16
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m1.10 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m2.61 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 33ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2686b8d: build with burbo
|
|
8
|
+
- 2686b8d: remove private dependencies
|
|
9
|
+
- Updated dependencies [2686b8d]
|
|
10
|
+
- Updated dependencies [2686b8d]
|
|
11
|
+
- keq@5.0.0-alpha.9
|
|
12
|
+
|
|
13
|
+
## 5.0.0-alpha.8
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 0873c7e: Incorrect build before release.
|
|
18
|
+
- Updated dependencies [0873c7e]
|
|
19
|
+
- keq@5.0.0-alpha.8
|
|
20
|
+
|
|
3
21
|
## 5.0.0-alpha.7
|
|
4
22
|
|
|
5
23
|
### Major Changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { KeqMiddleware } from 'keq';
|
|
2
|
+
export declare function setBaseUrl(base: string): KeqMiddleware;
|
|
3
|
+
export declare function setOrigin(origin: string): KeqMiddleware;
|
|
4
|
+
export declare function setHost(host: string): KeqMiddleware;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAGnC,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAwBtD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAgBvD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAKnD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
setBaseUrl: () => setBaseUrl,
|
|
24
|
+
setHost: () => setHost,
|
|
25
|
+
setOrigin: () => setOrigin
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
function setBaseUrl(base) {
|
|
29
|
+
if (base.startsWith("/")) {
|
|
30
|
+
return async function setBaseUrl2(ctx, next) {
|
|
31
|
+
ctx.request.url.pathname = `${base.replace(/\/$/, "")}/${ctx.request.url.pathname.replace(/^\//, "")}`;
|
|
32
|
+
await next();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const url = new URL(base);
|
|
36
|
+
return async function setBaseUrl2(ctx, next) {
|
|
37
|
+
ctx.request.url.host = url.host;
|
|
38
|
+
ctx.request.url.protocol = url.protocol;
|
|
39
|
+
ctx.request.url.pathname = `${url.pathname.replace(/\/$/, "")}/${ctx.request.url.pathname.replace(/^\//, "")}`;
|
|
40
|
+
if (url.port) {
|
|
41
|
+
ctx.request.url.port = url.port;
|
|
42
|
+
}
|
|
43
|
+
await next();
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function setOrigin(origin) {
|
|
47
|
+
const url = new URL(origin);
|
|
48
|
+
return async function setOrigin2(ctx, next) {
|
|
49
|
+
ctx.request.url.host = url.host;
|
|
50
|
+
ctx.request.url.protocol = url.protocol;
|
|
51
|
+
if (url.port) {
|
|
52
|
+
ctx.request.url.port = url.port;
|
|
53
|
+
}
|
|
54
|
+
await next();
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function setHost(host) {
|
|
58
|
+
return async function setHost2(ctx, next) {
|
|
59
|
+
ctx.request.url.host = host;
|
|
60
|
+
await next();
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
setBaseUrl,
|
|
66
|
+
setHost,
|
|
67
|
+
setOrigin
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { KeqMiddleware } from 'keq'\n\n\nexport function setBaseUrl(base: string): KeqMiddleware {\n if (base.startsWith('/')) {\n return async function setBaseUrl(ctx, next) {\n ctx.request.url.pathname = `${base.replace(/\\/$/, '')}/${ctx.request.url.pathname.replace(/^\\//, '')}`\n await next()\n }\n }\n\n const url = new URL(base)\n\n return async function setBaseUrl(ctx, next) {\n ctx.request.url.host = url.host\n ctx.request.url.protocol = url.protocol\n ctx.request.url.pathname = `${url.pathname.replace(/\\/$/, '')}/${ctx.request.url.pathname.replace(/^\\//, '')}`\n\n // Fix bug in chrome@74 bug:\n // url.port will return `\"\"` if the base url not contain port.\n // And when ctx.response.url.port is set to `\"\"`, `null` or `undefined`, it will return `:0` in ctx.response.url.href\n if (url.port) {\n ctx.request.url.port = url.port\n }\n\n await next()\n }\n}\n\nexport function setOrigin(origin: string): KeqMiddleware {\n const url = new URL(origin)\n\n return async function setOrigin(ctx, next) {\n ctx.request.url.host = url.host\n ctx.request.url.protocol = url.protocol\n\n // Fix bug in chrome@74 bug:\n // url.port will return `\"\"` if the base url not contain port.\n // And when ctx.response.url.port is set to `\"\"`, `null` or `undefined`, it will return `:0` in ctx.response.url.href\n if (url.port) {\n ctx.request.url.port = url.port\n }\n\n await next()\n }\n}\n\nexport function setHost(host: string): KeqMiddleware {\n return async function setHost(ctx, next) {\n ctx.request.url.host = host\n await next()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,WAAW,MAA6B;AACtD,MAAI,KAAK,WAAW,GAAG,GAAG;AACxB,WAAO,eAAeA,YAAW,KAAK,MAAM;AAC1C,UAAI,QAAQ,IAAI,WAAW,GAAG,KAAK,QAAQ,OAAO,EAAE,CAAC,IAAI,IAAI,QAAQ,IAAI,SAAS,QAAQ,OAAO,EAAE,CAAC;AACpG,YAAM,KAAK;AAAA,IACb;AAAA,EACF;AAEA,QAAM,MAAM,IAAI,IAAI,IAAI;AAExB,SAAO,eAAeA,YAAW,KAAK,MAAM;AAC1C,QAAI,QAAQ,IAAI,OAAO,IAAI;AAC3B,QAAI,QAAQ,IAAI,WAAW,IAAI;AAC/B,QAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,SAAS,QAAQ,OAAO,EAAE,CAAC,IAAI,IAAI,QAAQ,IAAI,SAAS,QAAQ,OAAO,EAAE,CAAC;AAK5G,QAAI,IAAI,MAAM;AACZ,UAAI,QAAQ,IAAI,OAAO,IAAI;AAAA,IAC7B;AAEA,UAAM,KAAK;AAAA,EACb;AACF;AAEO,SAAS,UAAU,QAA+B;AACvD,QAAM,MAAM,IAAI,IAAI,MAAM;AAE1B,SAAO,eAAeC,WAAU,KAAK,MAAM;AACzC,QAAI,QAAQ,IAAI,OAAO,IAAI;AAC3B,QAAI,QAAQ,IAAI,WAAW,IAAI;AAK/B,QAAI,IAAI,MAAM;AACZ,UAAI,QAAQ,IAAI,OAAO,IAAI;AAAA,IAC7B;AAEA,UAAM,KAAK;AAAA,EACb;AACF;AAEO,SAAS,QAAQ,MAA6B;AACnD,SAAO,eAAeC,SAAQ,KAAK,MAAM;AACvC,QAAI,QAAQ,IAAI,OAAO;AACvB,UAAM,KAAK;AAAA,EACb;AACF;","names":["setBaseUrl","setOrigin","setHost"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function setBaseUrl(base) {
|
|
3
|
+
if (base.startsWith("/")) {
|
|
4
|
+
return async function setBaseUrl2(ctx, next) {
|
|
5
|
+
ctx.request.url.pathname = `${base.replace(/\/$/, "")}/${ctx.request.url.pathname.replace(/^\//, "")}`;
|
|
6
|
+
await next();
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const url = new URL(base);
|
|
10
|
+
return async function setBaseUrl2(ctx, next) {
|
|
11
|
+
ctx.request.url.host = url.host;
|
|
12
|
+
ctx.request.url.protocol = url.protocol;
|
|
13
|
+
ctx.request.url.pathname = `${url.pathname.replace(/\/$/, "")}/${ctx.request.url.pathname.replace(/^\//, "")}`;
|
|
14
|
+
if (url.port) {
|
|
15
|
+
ctx.request.url.port = url.port;
|
|
16
|
+
}
|
|
17
|
+
await next();
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function setOrigin(origin) {
|
|
21
|
+
const url = new URL(origin);
|
|
22
|
+
return async function setOrigin2(ctx, next) {
|
|
23
|
+
ctx.request.url.host = url.host;
|
|
24
|
+
ctx.request.url.protocol = url.protocol;
|
|
25
|
+
if (url.port) {
|
|
26
|
+
ctx.request.url.port = url.port;
|
|
27
|
+
}
|
|
28
|
+
await next();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function setHost(host) {
|
|
32
|
+
return async function setHost2(ctx, next) {
|
|
33
|
+
ctx.request.url.host = host;
|
|
34
|
+
await next();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
setBaseUrl,
|
|
39
|
+
setHost,
|
|
40
|
+
setOrigin
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { KeqMiddleware } from 'keq'\n\n\nexport function setBaseUrl(base: string): KeqMiddleware {\n if (base.startsWith('/')) {\n return async function setBaseUrl(ctx, next) {\n ctx.request.url.pathname = `${base.replace(/\\/$/, '')}/${ctx.request.url.pathname.replace(/^\\//, '')}`\n await next()\n }\n }\n\n const url = new URL(base)\n\n return async function setBaseUrl(ctx, next) {\n ctx.request.url.host = url.host\n ctx.request.url.protocol = url.protocol\n ctx.request.url.pathname = `${url.pathname.replace(/\\/$/, '')}/${ctx.request.url.pathname.replace(/^\\//, '')}`\n\n // Fix bug in chrome@74 bug:\n // url.port will return `\"\"` if the base url not contain port.\n // And when ctx.response.url.port is set to `\"\"`, `null` or `undefined`, it will return `:0` in ctx.response.url.href\n if (url.port) {\n ctx.request.url.port = url.port\n }\n\n await next()\n }\n}\n\nexport function setOrigin(origin: string): KeqMiddleware {\n const url = new URL(origin)\n\n return async function setOrigin(ctx, next) {\n ctx.request.url.host = url.host\n ctx.request.url.protocol = url.protocol\n\n // Fix bug in chrome@74 bug:\n // url.port will return `\"\"` if the base url not contain port.\n // And when ctx.response.url.port is set to `\"\"`, `null` or `undefined`, it will return `:0` in ctx.response.url.href\n if (url.port) {\n ctx.request.url.port = url.port\n }\n\n await next()\n }\n}\n\nexport function setHost(host: string): KeqMiddleware {\n return async function setHost(ctx, next) {\n ctx.request.url.host = host\n await next()\n }\n}\n"],"mappings":";AAGO,SAAS,WAAW,MAA6B;AACtD,MAAI,KAAK,WAAW,GAAG,GAAG;AACxB,WAAO,eAAeA,YAAW,KAAK,MAAM;AAC1C,UAAI,QAAQ,IAAI,WAAW,GAAG,KAAK,QAAQ,OAAO,EAAE,CAAC,IAAI,IAAI,QAAQ,IAAI,SAAS,QAAQ,OAAO,EAAE,CAAC;AACpG,YAAM,KAAK;AAAA,IACb;AAAA,EACF;AAEA,QAAM,MAAM,IAAI,IAAI,IAAI;AAExB,SAAO,eAAeA,YAAW,KAAK,MAAM;AAC1C,QAAI,QAAQ,IAAI,OAAO,IAAI;AAC3B,QAAI,QAAQ,IAAI,WAAW,IAAI;AAC/B,QAAI,QAAQ,IAAI,WAAW,GAAG,IAAI,SAAS,QAAQ,OAAO,EAAE,CAAC,IAAI,IAAI,QAAQ,IAAI,SAAS,QAAQ,OAAO,EAAE,CAAC;AAK5G,QAAI,IAAI,MAAM;AACZ,UAAI,QAAQ,IAAI,OAAO,IAAI;AAAA,IAC7B;AAEA,UAAM,KAAK;AAAA,EACb;AACF;AAEO,SAAS,UAAU,QAA+B;AACvD,QAAM,MAAM,IAAI,IAAI,MAAM;AAE1B,SAAO,eAAeC,WAAU,KAAK,MAAM;AACzC,QAAI,QAAQ,IAAI,OAAO,IAAI;AAC3B,QAAI,QAAQ,IAAI,WAAW,IAAI;AAK/B,QAAI,IAAI,MAAM;AACZ,UAAI,QAAQ,IAAI,OAAO,IAAI;AAAA,IAC7B;AAEA,UAAM,KAAK;AAAA,EACb;AACF;AAEO,SAAS,QAAQ,MAA6B;AACnD,SAAO,eAAeC,SAAQ,KAAK,MAAM;AACvC,QAAI,QAAQ,IAAI,OAAO;AACvB,UAAM,KAAK;AAAA,EACb;AACF;","names":["setBaseUrl","setOrigin","setHost"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keq-request/url",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.9",
|
|
4
4
|
"description": "Set request url",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"request",
|
|
@@ -34,11 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^20.19.24",
|
|
37
|
-
"keq": "5.0.0-alpha.
|
|
38
|
-
"@keq-request/test": "5.0.0-alpha.7"
|
|
37
|
+
"keq": "5.0.0-alpha.9"
|
|
39
38
|
},
|
|
40
39
|
"peerDependencies": {
|
|
41
|
-
"keq": "^5.0.0-alpha.
|
|
40
|
+
"keq": "^5.0.0-alpha.9"
|
|
42
41
|
},
|
|
43
42
|
"scripts": {
|
|
44
43
|
"build": "tsup",
|