@keq-request/url 5.0.0-alpha.11 → 5.0.0-alpha.13
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 +14 -0
- package/dist/index.js +2 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- keq@5.0.0-alpha.13
|
|
8
|
+
|
|
9
|
+
## 5.0.0-alpha.12
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 581815a: ensure compatibility
|
|
14
|
+
- Updated dependencies [581815a]
|
|
15
|
+
- keq@5.0.0-alpha.12
|
|
16
|
+
|
|
3
17
|
## 5.0.0-alpha.11
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
28
28
|
function setBaseUrl(base) {
|
|
29
29
|
if (base.startsWith("/")) {
|
|
30
30
|
return async function setBaseUrl2(ctx, next) {
|
|
31
|
-
ctx.request.url.pathname =
|
|
31
|
+
ctx.request.url.pathname = "".concat(base.replace(/\/$/, ""), "/").concat(ctx.request.url.pathname.replace(/^\//, ""));
|
|
32
32
|
await next();
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -36,7 +36,7 @@ function setBaseUrl(base) {
|
|
|
36
36
|
return async function setBaseUrl2(ctx, next) {
|
|
37
37
|
ctx.request.url.host = url.host;
|
|
38
38
|
ctx.request.url.protocol = url.protocol;
|
|
39
|
-
ctx.request.url.pathname =
|
|
39
|
+
ctx.request.url.pathname = "".concat(url.pathname.replace(/\/$/, ""), "/").concat(ctx.request.url.pathname.replace(/^\//, ""));
|
|
40
40
|
if (url.port) {
|
|
41
41
|
ctx.request.url.port = url.port;
|
|
42
42
|
}
|
|
@@ -60,10 +60,4 @@ function setHost(host) {
|
|
|
60
60
|
await next();
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
setBaseUrl,
|
|
66
|
-
setHost,
|
|
67
|
-
setOrigin
|
|
68
|
-
});
|
|
69
63
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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,
|
|
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;AAA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, next) {
|
|
5
|
-
ctx.request.url.pathname =
|
|
5
|
+
ctx.request.url.pathname = "".concat(base.replace(/\/$/, ""), "/").concat(ctx.request.url.pathname.replace(/^\//, ""));
|
|
6
6
|
await next();
|
|
7
7
|
};
|
|
8
8
|
}
|
|
@@ -10,7 +10,7 @@ function setBaseUrl(base) {
|
|
|
10
10
|
return async function setBaseUrl2(ctx, next) {
|
|
11
11
|
ctx.request.url.host = url.host;
|
|
12
12
|
ctx.request.url.protocol = url.protocol;
|
|
13
|
-
ctx.request.url.pathname =
|
|
13
|
+
ctx.request.url.pathname = "".concat(url.pathname.replace(/\/$/, ""), "/").concat(ctx.request.url.pathname.replace(/^\//, ""));
|
|
14
14
|
if (url.port) {
|
|
15
15
|
ctx.request.url.port = url.port;
|
|
16
16
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +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,
|
|
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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
|
|
3
|
+
"version": "5.0.0-alpha.13",
|
|
4
4
|
"description": "Set request url",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"request",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^20.19.24",
|
|
37
|
-
"keq": "5.0.0-alpha.
|
|
37
|
+
"keq": "5.0.0-alpha.13"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"keq": "^5.0.0-alpha.
|
|
40
|
+
"keq": "^5.0.0-alpha.13"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsup",
|