url-operator 0.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/LICENSE +21 -0
- package/README.md +75 -0
- package/lib/es2015/append-pathname.d.ts +1 -0
- package/lib/es2015/append-pathname.js +19 -0
- package/lib/es2015/append-pathname.js.map +1 -0
- package/lib/es2015/append-search-param.d.ts +1 -0
- package/lib/es2015/append-search-param.js +12 -0
- package/lib/es2015/append-search-param.js.map +1 -0
- package/lib/es2015/index.d.ts +12 -0
- package/lib/es2015/index.js +29 -0
- package/lib/es2015/index.js.map +1 -0
- package/lib/es2015/set-hash.d.ts +1 -0
- package/lib/es2015/set-hash.js +10 -0
- package/lib/es2015/set-hash.js.map +1 -0
- package/lib/es2015/set-host.d.ts +1 -0
- package/lib/es2015/set-host.js +10 -0
- package/lib/es2015/set-host.js.map +1 -0
- package/lib/es2015/set-password.d.ts +1 -0
- package/lib/es2015/set-password.js +10 -0
- package/lib/es2015/set-password.js.map +1 -0
- package/lib/es2015/set-pathname.d.ts +1 -0
- package/lib/es2015/set-pathname.js +10 -0
- package/lib/es2015/set-pathname.js.map +1 -0
- package/lib/es2015/set-port.d.ts +1 -0
- package/lib/es2015/set-port.js +10 -0
- package/lib/es2015/set-port.js.map +1 -0
- package/lib/es2015/set-protocol.d.ts +1 -0
- package/lib/es2015/set-protocol.js +12 -0
- package/lib/es2015/set-protocol.js.map +1 -0
- package/lib/es2015/set-search-param.d.ts +1 -0
- package/lib/es2015/set-search-param.js +12 -0
- package/lib/es2015/set-search-param.js.map +1 -0
- package/lib/es2015/set-search-params.d.ts +1 -0
- package/lib/es2015/set-search-params.js +14 -0
- package/lib/es2015/set-search-params.js.map +1 -0
- package/lib/es2015/set-search.d.ts +1 -0
- package/lib/es2015/set-search.js +10 -0
- package/lib/es2015/set-search.js.map +1 -0
- package/lib/es2015/set-username.d.ts +1 -0
- package/lib/es2015/set-username.js +10 -0
- package/lib/es2015/set-username.js.map +1 -0
- package/lib/es2018/append-pathname.d.ts +1 -0
- package/lib/es2018/append-pathname.js +19 -0
- package/lib/es2018/append-pathname.js.map +1 -0
- package/lib/es2018/append-search-param.d.ts +1 -0
- package/lib/es2018/append-search-param.js +12 -0
- package/lib/es2018/append-search-param.js.map +1 -0
- package/lib/es2018/index.d.ts +12 -0
- package/lib/es2018/index.js +29 -0
- package/lib/es2018/index.js.map +1 -0
- package/lib/es2018/set-hash.d.ts +1 -0
- package/lib/es2018/set-hash.js +10 -0
- package/lib/es2018/set-hash.js.map +1 -0
- package/lib/es2018/set-host.d.ts +1 -0
- package/lib/es2018/set-host.js +10 -0
- package/lib/es2018/set-host.js.map +1 -0
- package/lib/es2018/set-password.d.ts +1 -0
- package/lib/es2018/set-password.js +10 -0
- package/lib/es2018/set-password.js.map +1 -0
- package/lib/es2018/set-pathname.d.ts +1 -0
- package/lib/es2018/set-pathname.js +10 -0
- package/lib/es2018/set-pathname.js.map +1 -0
- package/lib/es2018/set-port.d.ts +1 -0
- package/lib/es2018/set-port.js +10 -0
- package/lib/es2018/set-port.js.map +1 -0
- package/lib/es2018/set-protocol.d.ts +1 -0
- package/lib/es2018/set-protocol.js +12 -0
- package/lib/es2018/set-protocol.js.map +1 -0
- package/lib/es2018/set-search-param.d.ts +1 -0
- package/lib/es2018/set-search-param.js +12 -0
- package/lib/es2018/set-search-param.js.map +1 -0
- package/lib/es2018/set-search-params.d.ts +1 -0
- package/lib/es2018/set-search-params.js +14 -0
- package/lib/es2018/set-search-params.js.map +1 -0
- package/lib/es2018/set-search.d.ts +1 -0
- package/lib/es2018/set-search.js +10 -0
- package/lib/es2018/set-search.js.map +1 -0
- package/lib/es2018/set-username.d.ts +1 -0
- package/lib/es2018/set-username.js +10 -0
- package/lib/es2018/set-username.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 BlackGlory <woshenmedoubuzhidao@blackglory.me>
|
|
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,75 @@
|
|
|
1
|
+
# url-operator
|
|
2
|
+
## Install
|
|
3
|
+
```sh
|
|
4
|
+
npm install --save url-operator
|
|
5
|
+
# or
|
|
6
|
+
yarn add url-operator
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## API
|
|
10
|
+
### setProtocol
|
|
11
|
+
```ts
|
|
12
|
+
function setProtocol(url: string | URL, protocol: string): URL
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### setUsername
|
|
16
|
+
```ts
|
|
17
|
+
function setUsername(url: string | URL, username: string): URL
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### setPassword
|
|
21
|
+
```ts
|
|
22
|
+
function setPassword(url: string | URL, password: string): URL
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### setHost
|
|
26
|
+
```ts
|
|
27
|
+
function setHost(url: string | URL, host: string): URL
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### setPort
|
|
31
|
+
```ts
|
|
32
|
+
function setPort(url: string | URL, port: number): URL
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### setPathname
|
|
36
|
+
```ts
|
|
37
|
+
function setPathname(url: string | URL, pathname: string): URL
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### appendPathname
|
|
41
|
+
```ts
|
|
42
|
+
function appendPathname(url: string | URL, pathname: string): URL
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### setSearch
|
|
46
|
+
```ts
|
|
47
|
+
function setSearch(url: string | URL, search: string): URL
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### setSearchParam
|
|
51
|
+
```ts
|
|
52
|
+
function setSearchParam(url: string | URL, name: string, value: string | number): URL
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### setSearchParams
|
|
56
|
+
```ts
|
|
57
|
+
function setSearchParams(
|
|
58
|
+
url: string | URL
|
|
59
|
+
, searchParams: Record<string, string | number>
|
|
60
|
+
): URL
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### appendSearchParam
|
|
64
|
+
```ts
|
|
65
|
+
function appendSearchParam(
|
|
66
|
+
url: string | URL
|
|
67
|
+
, name: string
|
|
68
|
+
, value: string | number
|
|
69
|
+
): URL
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### setHash
|
|
73
|
+
```ts
|
|
74
|
+
function setHash(url: string | URL, hash: string): URL
|
|
75
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function appendPathname(url: string | URL, pathname: string): URL;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appendPathname = void 0;
|
|
4
|
+
const prelude_1 = require("@blackglory/prelude");
|
|
5
|
+
function appendPathname(url, pathname) {
|
|
6
|
+
const baseURL = (0, prelude_1.go)(() => {
|
|
7
|
+
const baseURL = new URL(url);
|
|
8
|
+
if (!baseURL.pathname.endsWith('/')) {
|
|
9
|
+
baseURL.pathname = `${baseURL.pathname}/`;
|
|
10
|
+
}
|
|
11
|
+
return baseURL;
|
|
12
|
+
});
|
|
13
|
+
const newURL = new URL(pathname.replace(/^\/*/, ''), baseURL);
|
|
14
|
+
newURL.search = baseURL.search;
|
|
15
|
+
newURL.hash = baseURL.hash;
|
|
16
|
+
return newURL;
|
|
17
|
+
}
|
|
18
|
+
exports.appendPathname = appendPathname;
|
|
19
|
+
//# sourceMappingURL=append-pathname.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append-pathname.js","sourceRoot":"","sources":["../../src/append-pathname.ts"],"names":[],"mappings":";;;AAAA,iDAAwC;AAExC,SAAgB,cAAc,CAAC,GAAiB,EAAE,QAAgB;IAChE,MAAM,OAAO,GAAG,IAAA,YAAE,EAAC,GAAG,EAAE;QACtB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACnC,OAAO,CAAC,QAAQ,GAAG,GAAG,OAAO,CAAC,QAAQ,GAAG,CAAA;SAC1C;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAC5B,OAAO,CACR,CAAA;IACD,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAlBD,wCAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function appendSearchParam(url: string | URL, name: string, value: string | number): URL;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appendSearchParam = void 0;
|
|
4
|
+
function appendSearchParam(url, name, value) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
const newSearchParams = new URLSearchParams(newURL.searchParams);
|
|
7
|
+
newSearchParams.append(name, value.toString());
|
|
8
|
+
newURL.search = newSearchParams.toString();
|
|
9
|
+
return newURL;
|
|
10
|
+
}
|
|
11
|
+
exports.appendSearchParam = appendSearchParam;
|
|
12
|
+
//# sourceMappingURL=append-search-param.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append-search-param.js","sourceRoot":"","sources":["../../src/append-search-param.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAC/B,GAAiB,EACjB,IAAY,EACZ,KAAsB;IAEtB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAChE,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IAE1C,OAAO,MAAM,CAAA;AACf,CAAC;AAZD,8CAYC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './set-protocol';
|
|
2
|
+
export * from './set-username';
|
|
3
|
+
export * from './set-password';
|
|
4
|
+
export * from './set-host';
|
|
5
|
+
export * from './set-port';
|
|
6
|
+
export * from './set-pathname';
|
|
7
|
+
export * from './append-pathname';
|
|
8
|
+
export * from './set-search';
|
|
9
|
+
export * from './set-search-param';
|
|
10
|
+
export * from './set-search-params';
|
|
11
|
+
export * from './append-search-param';
|
|
12
|
+
export * from './set-hash';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./set-protocol"), exports);
|
|
18
|
+
__exportStar(require("./set-username"), exports);
|
|
19
|
+
__exportStar(require("./set-password"), exports);
|
|
20
|
+
__exportStar(require("./set-host"), exports);
|
|
21
|
+
__exportStar(require("./set-port"), exports);
|
|
22
|
+
__exportStar(require("./set-pathname"), exports);
|
|
23
|
+
__exportStar(require("./append-pathname"), exports);
|
|
24
|
+
__exportStar(require("./set-search"), exports);
|
|
25
|
+
__exportStar(require("./set-search-param"), exports);
|
|
26
|
+
__exportStar(require("./set-search-params"), exports);
|
|
27
|
+
__exportStar(require("./append-search-param"), exports);
|
|
28
|
+
__exportStar(require("./set-hash"), exports);
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,iDAA8B;AAC9B,iDAA8B;AAC9B,6CAA0B;AAC1B,6CAA0B;AAC1B,iDAA8B;AAC9B,oDAAiC;AACjC,+CAA4B;AAC5B,qDAAkC;AAClC,sDAAmC;AACnC,wDAAqC;AACrC,6CAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setHash(url: string | URL, hash: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setHash = void 0;
|
|
4
|
+
function setHash(url, hash) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.hash = hash;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setHash = setHash;
|
|
10
|
+
//# sourceMappingURL=set-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-hash.js","sourceRoot":"","sources":["../../src/set-hash.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,GAAiB,EAAE,IAAY;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;IAElB,OAAO,MAAM,CAAA;AACf,CAAC;AAND,0BAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setHost(url: string | URL, host: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setHost = void 0;
|
|
4
|
+
function setHost(url, host) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.host = host;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setHost = setHost;
|
|
10
|
+
//# sourceMappingURL=set-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-host.js","sourceRoot":"","sources":["../../src/set-host.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,GAAiB,EAAE,IAAY;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;IAElB,OAAO,MAAM,CAAA;AACf,CAAC;AAND,0BAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setPassword(url: string | URL, password: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setPassword = void 0;
|
|
4
|
+
function setPassword(url, password) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.password = password;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setPassword = setPassword;
|
|
10
|
+
//# sourceMappingURL=set-password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-password.js","sourceRoot":"","sources":["../../src/set-password.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAiB,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAND,kCAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setPathname(url: string | URL, pathname: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setPathname = void 0;
|
|
4
|
+
function setPathname(url, pathname) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.pathname = pathname;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setPathname = setPathname;
|
|
10
|
+
//# sourceMappingURL=set-pathname.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-pathname.js","sourceRoot":"","sources":["../../src/set-pathname.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAiB,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAND,kCAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setPort(url: string | URL, port: number): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setPort = void 0;
|
|
4
|
+
function setPort(url, port) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.port = port.toString();
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setPort = setPort;
|
|
10
|
+
//# sourceMappingURL=set-port.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-port.js","sourceRoot":"","sources":["../../src/set-port.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,GAAiB,EAAE,IAAY;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;IAE7B,OAAO,MAAM,CAAA;AACf,CAAC;AAND,0BAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setProtocol(url: string | URL, protocol: string): URL;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setProtocol = void 0;
|
|
4
|
+
function setProtocol(url, protocol) {
|
|
5
|
+
const oldURL = new URL(url);
|
|
6
|
+
const newURL = new URL(oldURL.href.replace(/^(\S+:)\/\//, protocol.endsWith(':')
|
|
7
|
+
? protocol
|
|
8
|
+
: `${protocol}://`));
|
|
9
|
+
return newURL;
|
|
10
|
+
}
|
|
11
|
+
exports.setProtocol = setProtocol;
|
|
12
|
+
//# sourceMappingURL=set-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-protocol.js","sourceRoot":"","sources":["../../src/set-protocol.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAiB,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAG3B,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,MAAM,CAAC,IAAI,CAAC,OAAO,CACjB,aAAa,EACb,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,GAAG,QAAQ,KAAK,CACnB,CACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAdD,kCAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setSearchParam(url: string | URL, name: string, value: string | number): URL;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSearchParam = void 0;
|
|
4
|
+
function setSearchParam(url, name, value) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
const newSearchParams = new URLSearchParams(newURL.searchParams);
|
|
7
|
+
newSearchParams.set(name, value.toString());
|
|
8
|
+
newURL.search = newSearchParams.toString();
|
|
9
|
+
return newURL;
|
|
10
|
+
}
|
|
11
|
+
exports.setSearchParam = setSearchParam;
|
|
12
|
+
//# sourceMappingURL=set-search-param.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-search-param.js","sourceRoot":"","sources":["../../src/set-search-param.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,GAAiB,EAAE,IAAY,EAAE,KAAsB;IACpF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAChE,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC3C,MAAM,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IAE1C,OAAO,MAAM,CAAA;AACf,CAAC;AARD,wCAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setSearchParams(url: string | URL, searchParams: Record<string, string | number>): URL;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSearchParams = void 0;
|
|
4
|
+
function setSearchParams(url, searchParams) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
const newSearchParams = new URLSearchParams(newURL.searchParams);
|
|
7
|
+
for (const [name, value] of Object.entries(searchParams)) {
|
|
8
|
+
newSearchParams.set(name, value.toString());
|
|
9
|
+
}
|
|
10
|
+
newURL.search = newSearchParams.toString();
|
|
11
|
+
return newURL;
|
|
12
|
+
}
|
|
13
|
+
exports.setSearchParams = setSearchParams;
|
|
14
|
+
//# sourceMappingURL=set-search-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-search-params.js","sourceRoot":"","sources":["../../src/set-search-params.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAC7B,GAAiB,EACjB,YAA6C;IAE7C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAChE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QACxD,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;KAC5C;IACD,MAAM,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IAE1C,OAAO,MAAM,CAAA;AACf,CAAC;AAbD,0CAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setSearch(url: string | URL, search: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSearch = void 0;
|
|
4
|
+
function setSearch(url, search) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.search = search;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setSearch = setSearch;
|
|
10
|
+
//# sourceMappingURL=set-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-search.js","sourceRoot":"","sources":["../../src/set-search.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,GAAiB,EAAE,MAAc;IACzD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;IAEtB,OAAO,MAAM,CAAA;AACf,CAAC;AAND,8BAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setUsername(url: string | URL, username: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setUsername = void 0;
|
|
4
|
+
function setUsername(url, username) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.username = username;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setUsername = setUsername;
|
|
10
|
+
//# sourceMappingURL=set-username.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-username.js","sourceRoot":"","sources":["../../src/set-username.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAiB,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAND,kCAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function appendPathname(url: string | URL, pathname: string): URL;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appendPathname = void 0;
|
|
4
|
+
const prelude_1 = require("@blackglory/prelude");
|
|
5
|
+
function appendPathname(url, pathname) {
|
|
6
|
+
const baseURL = (0, prelude_1.go)(() => {
|
|
7
|
+
const baseURL = new URL(url);
|
|
8
|
+
if (!baseURL.pathname.endsWith('/')) {
|
|
9
|
+
baseURL.pathname = `${baseURL.pathname}/`;
|
|
10
|
+
}
|
|
11
|
+
return baseURL;
|
|
12
|
+
});
|
|
13
|
+
const newURL = new URL(pathname.replace(/^\/*/, ''), baseURL);
|
|
14
|
+
newURL.search = baseURL.search;
|
|
15
|
+
newURL.hash = baseURL.hash;
|
|
16
|
+
return newURL;
|
|
17
|
+
}
|
|
18
|
+
exports.appendPathname = appendPathname;
|
|
19
|
+
//# sourceMappingURL=append-pathname.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append-pathname.js","sourceRoot":"","sources":["../../src/append-pathname.ts"],"names":[],"mappings":";;;AAAA,iDAAwC;AAExC,SAAgB,cAAc,CAAC,GAAiB,EAAE,QAAgB;IAChE,MAAM,OAAO,GAAG,IAAA,YAAE,EAAC,GAAG,EAAE;QACtB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACnC,OAAO,CAAC,QAAQ,GAAG,GAAG,OAAO,CAAC,QAAQ,GAAG,CAAA;SAC1C;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAC5B,OAAO,CACR,CAAA;IACD,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC9B,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAlBD,wCAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function appendSearchParam(url: string | URL, name: string, value: string | number): URL;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appendSearchParam = void 0;
|
|
4
|
+
function appendSearchParam(url, name, value) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
const newSearchParams = new URLSearchParams(newURL.searchParams);
|
|
7
|
+
newSearchParams.append(name, value.toString());
|
|
8
|
+
newURL.search = newSearchParams.toString();
|
|
9
|
+
return newURL;
|
|
10
|
+
}
|
|
11
|
+
exports.appendSearchParam = appendSearchParam;
|
|
12
|
+
//# sourceMappingURL=append-search-param.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append-search-param.js","sourceRoot":"","sources":["../../src/append-search-param.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAC/B,GAAiB,EACjB,IAAY,EACZ,KAAsB;IAEtB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAChE,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IAE1C,OAAO,MAAM,CAAA;AACf,CAAC;AAZD,8CAYC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './set-protocol';
|
|
2
|
+
export * from './set-username';
|
|
3
|
+
export * from './set-password';
|
|
4
|
+
export * from './set-host';
|
|
5
|
+
export * from './set-port';
|
|
6
|
+
export * from './set-pathname';
|
|
7
|
+
export * from './append-pathname';
|
|
8
|
+
export * from './set-search';
|
|
9
|
+
export * from './set-search-param';
|
|
10
|
+
export * from './set-search-params';
|
|
11
|
+
export * from './append-search-param';
|
|
12
|
+
export * from './set-hash';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./set-protocol"), exports);
|
|
18
|
+
__exportStar(require("./set-username"), exports);
|
|
19
|
+
__exportStar(require("./set-password"), exports);
|
|
20
|
+
__exportStar(require("./set-host"), exports);
|
|
21
|
+
__exportStar(require("./set-port"), exports);
|
|
22
|
+
__exportStar(require("./set-pathname"), exports);
|
|
23
|
+
__exportStar(require("./append-pathname"), exports);
|
|
24
|
+
__exportStar(require("./set-search"), exports);
|
|
25
|
+
__exportStar(require("./set-search-param"), exports);
|
|
26
|
+
__exportStar(require("./set-search-params"), exports);
|
|
27
|
+
__exportStar(require("./append-search-param"), exports);
|
|
28
|
+
__exportStar(require("./set-hash"), exports);
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,iDAA8B;AAC9B,iDAA8B;AAC9B,6CAA0B;AAC1B,6CAA0B;AAC1B,iDAA8B;AAC9B,oDAAiC;AACjC,+CAA4B;AAC5B,qDAAkC;AAClC,sDAAmC;AACnC,wDAAqC;AACrC,6CAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setHash(url: string | URL, hash: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setHash = void 0;
|
|
4
|
+
function setHash(url, hash) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.hash = hash;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setHash = setHash;
|
|
10
|
+
//# sourceMappingURL=set-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-hash.js","sourceRoot":"","sources":["../../src/set-hash.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,GAAiB,EAAE,IAAY;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;IAElB,OAAO,MAAM,CAAA;AACf,CAAC;AAND,0BAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setHost(url: string | URL, host: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setHost = void 0;
|
|
4
|
+
function setHost(url, host) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.host = host;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setHost = setHost;
|
|
10
|
+
//# sourceMappingURL=set-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-host.js","sourceRoot":"","sources":["../../src/set-host.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,GAAiB,EAAE,IAAY;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;IAElB,OAAO,MAAM,CAAA;AACf,CAAC;AAND,0BAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setPassword(url: string | URL, password: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setPassword = void 0;
|
|
4
|
+
function setPassword(url, password) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.password = password;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setPassword = setPassword;
|
|
10
|
+
//# sourceMappingURL=set-password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-password.js","sourceRoot":"","sources":["../../src/set-password.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAiB,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAND,kCAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setPathname(url: string | URL, pathname: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setPathname = void 0;
|
|
4
|
+
function setPathname(url, pathname) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.pathname = pathname;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setPathname = setPathname;
|
|
10
|
+
//# sourceMappingURL=set-pathname.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-pathname.js","sourceRoot":"","sources":["../../src/set-pathname.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAiB,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAND,kCAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setPort(url: string | URL, port: number): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setPort = void 0;
|
|
4
|
+
function setPort(url, port) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.port = port.toString();
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setPort = setPort;
|
|
10
|
+
//# sourceMappingURL=set-port.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-port.js","sourceRoot":"","sources":["../../src/set-port.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,GAAiB,EAAE,IAAY;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;IAE7B,OAAO,MAAM,CAAA;AACf,CAAC;AAND,0BAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setProtocol(url: string | URL, protocol: string): URL;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setProtocol = void 0;
|
|
4
|
+
function setProtocol(url, protocol) {
|
|
5
|
+
const oldURL = new URL(url);
|
|
6
|
+
const newURL = new URL(oldURL.href.replace(/^(\S+:)\/\//, protocol.endsWith(':')
|
|
7
|
+
? protocol
|
|
8
|
+
: `${protocol}://`));
|
|
9
|
+
return newURL;
|
|
10
|
+
}
|
|
11
|
+
exports.setProtocol = setProtocol;
|
|
12
|
+
//# sourceMappingURL=set-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-protocol.js","sourceRoot":"","sources":["../../src/set-protocol.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAiB,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAG3B,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,MAAM,CAAC,IAAI,CAAC,OAAO,CACjB,aAAa,EACb,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,GAAG,QAAQ,KAAK,CACnB,CACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAdD,kCAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setSearchParam(url: string | URL, name: string, value: string | number): URL;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSearchParam = void 0;
|
|
4
|
+
function setSearchParam(url, name, value) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
const newSearchParams = new URLSearchParams(newURL.searchParams);
|
|
7
|
+
newSearchParams.set(name, value.toString());
|
|
8
|
+
newURL.search = newSearchParams.toString();
|
|
9
|
+
return newURL;
|
|
10
|
+
}
|
|
11
|
+
exports.setSearchParam = setSearchParam;
|
|
12
|
+
//# sourceMappingURL=set-search-param.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-search-param.js","sourceRoot":"","sources":["../../src/set-search-param.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,GAAiB,EAAE,IAAY,EAAE,KAAsB;IACpF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAChE,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC3C,MAAM,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IAE1C,OAAO,MAAM,CAAA;AACf,CAAC;AARD,wCAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setSearchParams(url: string | URL, searchParams: Record<string, string | number>): URL;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSearchParams = void 0;
|
|
4
|
+
function setSearchParams(url, searchParams) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
const newSearchParams = new URLSearchParams(newURL.searchParams);
|
|
7
|
+
for (const [name, value] of Object.entries(searchParams)) {
|
|
8
|
+
newSearchParams.set(name, value.toString());
|
|
9
|
+
}
|
|
10
|
+
newURL.search = newSearchParams.toString();
|
|
11
|
+
return newURL;
|
|
12
|
+
}
|
|
13
|
+
exports.setSearchParams = setSearchParams;
|
|
14
|
+
//# sourceMappingURL=set-search-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-search-params.js","sourceRoot":"","sources":["../../src/set-search-params.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAC7B,GAAiB,EACjB,YAA6C;IAE7C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAChE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QACxD,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;KAC5C;IACD,MAAM,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IAE1C,OAAO,MAAM,CAAA;AACf,CAAC;AAbD,0CAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setSearch(url: string | URL, search: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSearch = void 0;
|
|
4
|
+
function setSearch(url, search) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.search = search;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setSearch = setSearch;
|
|
10
|
+
//# sourceMappingURL=set-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-search.js","sourceRoot":"","sources":["../../src/set-search.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,GAAiB,EAAE,MAAc;IACzD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;IAEtB,OAAO,MAAM,CAAA;AACf,CAAC;AAND,8BAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setUsername(url: string | URL, username: string): URL;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setUsername = void 0;
|
|
4
|
+
function setUsername(url, username) {
|
|
5
|
+
const newURL = new URL(url);
|
|
6
|
+
newURL.username = username;
|
|
7
|
+
return newURL;
|
|
8
|
+
}
|
|
9
|
+
exports.setUsername = setUsername;
|
|
10
|
+
//# sourceMappingURL=set-username.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-username.js","sourceRoot":"","sources":["../../src/set-username.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAiB,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAE3B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC;AAND,kCAMC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "url-operator",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"files": [
|
|
7
|
+
"lib"
|
|
8
|
+
],
|
|
9
|
+
"main": "lib/es2018/index.js",
|
|
10
|
+
"types": "lib/es2018/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"repository": "git@github.com:BlackGlory/url-operator.git",
|
|
13
|
+
"author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src",
|
|
17
|
+
"test": "jest --runInBand --no-cache --config jest.config.js",
|
|
18
|
+
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
|
|
19
|
+
"test:coverage": "jest --runInBand --coverage --config jest.config.js",
|
|
20
|
+
"prepublishOnly": "run-s clean build",
|
|
21
|
+
"clean": "rimraf lib",
|
|
22
|
+
"build": "run-p build:*",
|
|
23
|
+
"build:es2015": "run-s build:es2015:*",
|
|
24
|
+
"build:es2015:compile": "tsc --project tsconfig.build.json --module commonjs --target es2015 --outDir lib/es2015",
|
|
25
|
+
"build:es2015:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib/es2015",
|
|
26
|
+
"build:es2018": "run-s build:es2018:*",
|
|
27
|
+
"build:es2018:compile": "tsc --project tsconfig.build.json --module commonjs --target es2018 --outDir lib/es2018",
|
|
28
|
+
"build:es2018:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib/es2018",
|
|
29
|
+
"release": "standard-version"
|
|
30
|
+
},
|
|
31
|
+
"husky": {
|
|
32
|
+
"hooks": {
|
|
33
|
+
"pre-commit": "run-s lint build test",
|
|
34
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@commitlint/cli": "^17.1.2",
|
|
39
|
+
"@commitlint/config-conventional": "^17.1.0",
|
|
40
|
+
"@types/jest": "^27.4.1",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
|
42
|
+
"@typescript-eslint/parser": "^5.40.1",
|
|
43
|
+
"eslint": "^8.25.0",
|
|
44
|
+
"husky": "4",
|
|
45
|
+
"jest": "^27.5.1",
|
|
46
|
+
"npm-run-all": "^4.1.5",
|
|
47
|
+
"rimraf": "^3.0.2",
|
|
48
|
+
"standard-version": "^9.5.0",
|
|
49
|
+
"ts-jest": "^27.1.3",
|
|
50
|
+
"tscpaths": "^0.0.9",
|
|
51
|
+
"tslib": "^2.3.1",
|
|
52
|
+
"typescript": "^4.6.2"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@blackglory/prelude": "^0.1.5"
|
|
56
|
+
}
|
|
57
|
+
}
|