@keq-request/url 5.0.0-alpha.10
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 +94 -0
- package/LICENSE +21 -0
- package/README.md +67 -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 +48 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 5.0.0-alpha.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e7eb9dc: Don't publish .turbo and jest.config.cts to npm
|
|
8
|
+
- 7343445: Incorrect build before release
|
|
9
|
+
- Updated dependencies [e7eb9dc]
|
|
10
|
+
- Updated dependencies [7343445]
|
|
11
|
+
- keq@5.0.0-alpha.10
|
|
12
|
+
|
|
13
|
+
## 5.0.0-alpha.9
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 2686b8d: build with burbo
|
|
18
|
+
- 2686b8d: remove private dependencies
|
|
19
|
+
- Updated dependencies [2686b8d]
|
|
20
|
+
- Updated dependencies [2686b8d]
|
|
21
|
+
- keq@5.0.0-alpha.9
|
|
22
|
+
|
|
23
|
+
## 5.0.0-alpha.8
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 0873c7e: Incorrect build before release.
|
|
28
|
+
- Updated dependencies [0873c7e]
|
|
29
|
+
- keq@5.0.0-alpha.8
|
|
30
|
+
|
|
31
|
+
## 5.0.0-alpha.7
|
|
32
|
+
|
|
33
|
+
### Major Changes
|
|
34
|
+
|
|
35
|
+
- 5175097: **BREAKING CHANGE:** group all packages under the @keq-request scope
|
|
36
|
+
|
|
37
|
+
- keq-cache => @keq-request/cache
|
|
38
|
+
- keq-headers => @keq-request/headers
|
|
39
|
+
- keq-cli => @keq-request/cli
|
|
40
|
+
- keq-url => @keq-request/url
|
|
41
|
+
- keq-exception => @keq-request/exception
|
|
42
|
+
|
|
43
|
+
### Minor Changes
|
|
44
|
+
|
|
45
|
+
- 153244f: **Feat:** setBaseUrl could prefix pathname.
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [153244f]
|
|
50
|
+
- Updated dependencies [153244f]
|
|
51
|
+
- Updated dependencies [153244f]
|
|
52
|
+
- Updated dependencies [153244f]
|
|
53
|
+
- Updated dependencies [153244f]
|
|
54
|
+
- Updated dependencies [7ff2162]
|
|
55
|
+
- Updated dependencies [153244f]
|
|
56
|
+
- Updated dependencies [153244f]
|
|
57
|
+
- Updated dependencies [153244f]
|
|
58
|
+
- Updated dependencies [153244f]
|
|
59
|
+
- Updated dependencies [153244f]
|
|
60
|
+
- keq@5.0.0-alpha.7
|
|
61
|
+
|
|
62
|
+
## [2.0.4](https://github.com/keq-request/keq-url/compare/v2.0.3...v2.0.4) (2024-08-09)
|
|
63
|
+
|
|
64
|
+
### Bug Fixes
|
|
65
|
+
|
|
66
|
+
- port is set to :0 in chrome@70 ([1c1ebfe](https://github.com/keq-request/keq-url/commit/1c1ebfe7e93550003c71a106c4beb8fe51f04cb1))
|
|
67
|
+
|
|
68
|
+
## [2.0.3](https://github.com/keq-request/keq-url/compare/v2.0.2...v2.0.3) (2024-07-20)
|
|
69
|
+
|
|
70
|
+
### Performance Improvements
|
|
71
|
+
|
|
72
|
+
- remove whatwg-url because mosts browsers had support ([29b9e31](https://github.com/keq-request/keq-url/commit/29b9e312a0d25a38824172cad98602a83e4dbb5f))
|
|
73
|
+
|
|
74
|
+
## [2.0.2](https://github.com/keq-request/keq-url/compare/v2.0.1...v2.0.2) (2024-05-13)
|
|
75
|
+
|
|
76
|
+
### Performance Improvements
|
|
77
|
+
|
|
78
|
+
- add middleware function name ([a4bbc81](https://github.com/keq-request/keq-url/commit/a4bbc81cb2edfc1fa589bfb09bdefbfdbebfb2f8))
|
|
79
|
+
|
|
80
|
+
## [2.0.1](https://github.com/keq-request/keq-url/compare/v2.0.0...v2.0.1) (2024-04-26)
|
|
81
|
+
|
|
82
|
+
### Miscellaneous Chores
|
|
83
|
+
|
|
84
|
+
- release 2.0.1 ([7928da9](https://github.com/keq-request/keq-url/commit/7928da931ded536aa26766745213868cbf0ee633))
|
|
85
|
+
|
|
86
|
+
## 2.0.0 (2024-04-26)
|
|
87
|
+
|
|
88
|
+
### Features
|
|
89
|
+
|
|
90
|
+
- first commit ([8545a32](https://github.com/keq-request/keq-url/commit/8545a32b4a0030e9c323c2fc1091d4e9f1f7d849))
|
|
91
|
+
|
|
92
|
+
### Miscellaneous Chores
|
|
93
|
+
|
|
94
|
+
- release 2.0.0 ([db3881b](https://github.com/keq-request/keq-url/commit/db3881b9b1c8e53c0d83644428ed68a7d5edc74e))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Val.istar.Guo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!-- title -->
|
|
2
|
+
<p align="center" style="padding-top: 41px">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/keq-request/keq/refs/heads/master/images/logo.svg" width="121" alt="logo" />
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<h2 align="center" style="text-align: center">KEQ-URL</h2>
|
|
7
|
+
<!-- title -->
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/keq-url)
|
|
10
|
+
[](https://www.npmjs.com/package/keq-url)
|
|
11
|
+
[](https://www.npmjs.com/package/keq-url)
|
|
12
|
+
[](https://www.npmjs.com/package/keq-url)
|
|
13
|
+
[](https://codecov.io/gh/keq-request/keq-url)
|
|
14
|
+
|
|
15
|
+
[Document EN]: https://keq-request.github.io/guide/libraries/keq-url
|
|
16
|
+
[Document CN]: https://keq-request.github.io/zh/guide/libraries/keq-url
|
|
17
|
+
|
|
18
|
+
[**Document**][Document EN] | [**中文文档**][Document CN]
|
|
19
|
+
|
|
20
|
+
[Keq](https://github.com/keq-request/keq) middleware for setting the request url.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### `setBaseUrl(baseUrl)`
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { request } from "keq";
|
|
28
|
+
import { setBaseUrl, setHost } from "keq-url";
|
|
29
|
+
|
|
30
|
+
request.use(setBaseUrl("http://example.com/api"));
|
|
31
|
+
|
|
32
|
+
await request.get("/test");
|
|
33
|
+
// it will send request to 'http://example.com/api/test'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### `setOrigin(origin)`
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { request } from "keq";
|
|
40
|
+
import { setOrigin } from "keq-url";
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
await request.get("http://test.com/test");
|
|
44
|
+
.use(setOrigin("http://example.com:8080"));
|
|
45
|
+
// it will send request to 'http://example.com:8080/test'
|
|
46
|
+
|
|
47
|
+
// and prefix pathname is also possible
|
|
48
|
+
await request.get("http://test.com/test");
|
|
49
|
+
.use(setOrigin("/api"));
|
|
50
|
+
// it will send request to 'http://test.com:8080/api/test'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### `setHost(host)`
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { request } from "keq";
|
|
57
|
+
import { setHost } from "keq-url";
|
|
58
|
+
|
|
59
|
+
request.use(setHost("example.com"));
|
|
60
|
+
|
|
61
|
+
await request.get("http://test.com/test");
|
|
62
|
+
// it will send request to 'http://example.com/test'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Contributing & Development
|
|
66
|
+
|
|
67
|
+
If there is any doubt, it is very welcome to discuss the issue together.
|
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
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@keq-request/url",
|
|
3
|
+
"version": "5.0.0-alpha.10",
|
|
4
|
+
"description": "Set request url",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"request",
|
|
7
|
+
"superagent",
|
|
8
|
+
"fetch",
|
|
9
|
+
"node",
|
|
10
|
+
"nodejs",
|
|
11
|
+
"browser",
|
|
12
|
+
"middleware",
|
|
13
|
+
"middlewares",
|
|
14
|
+
"url"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/keq-request/keq#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/keq-request/keq/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/keq-request/keq.git"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Val.istar.Guo <val.istar.guo@gmail.com>",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"require": "./dist/index.js",
|
|
32
|
+
"import": "./dist/index.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.19.24",
|
|
37
|
+
"keq": "5.0.0-alpha.10"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"keq": "^5.0.0-alpha.10"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsup",
|
|
44
|
+
"dev": "tsup --watch",
|
|
45
|
+
"test": "jest",
|
|
46
|
+
"test:update": "jest -u"
|
|
47
|
+
}
|
|
48
|
+
}
|