@depup/whatwg-url 16.0.1-depup.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.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Sebastian Mayr
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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @depup/whatwg-url
2
+
3
+ > Dependency-bumped version of [whatwg-url](https://www.npmjs.com/package/whatwg-url)
4
+
5
+ Generated by [DepUp](https://github.com/depup/npm) -- all production
6
+ dependencies bumped to latest versions.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @depup/whatwg-url
12
+ ```
13
+
14
+ | Field | Value |
15
+ |-------|-------|
16
+ | Original | [whatwg-url](https://www.npmjs.com/package/whatwg-url) @ 16.0.1 |
17
+ | Processed | 2026-03-17 |
18
+ | Smoke test | passed |
19
+ | Deps updated | 1 |
20
+
21
+ ## Dependency Changes
22
+
23
+ | Dependency | From | To |
24
+ |------------|------|-----|
25
+ | @exodus/bytes | ^1.11.0 | ^1.15.0 |
26
+
27
+ ---
28
+
29
+ Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/whatwg-url
30
+
31
+ License inherited from the original package.
package/changes.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "bumped": {
3
+ "@exodus/bytes": {
4
+ "from": "^1.11.0",
5
+ "to": "^1.15.0"
6
+ }
7
+ },
8
+ "timestamp": "2026-03-17T16:39:35.176Z",
9
+ "totalUpdated": 1
10
+ }
package/index.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ const { URL, URLSearchParams } = require("./webidl2js-wrapper");
4
+ const urlStateMachine = require("./lib/url-state-machine");
5
+ const percentEncoding = require("./lib/percent-encoding");
6
+
7
+ const sharedGlobalObject = { Array, Object, Promise, String, TypeError };
8
+ URL.install(sharedGlobalObject, ["Window"]);
9
+ URLSearchParams.install(sharedGlobalObject, ["Window"]);
10
+
11
+ exports.URL = sharedGlobalObject.URL;
12
+ exports.URLSearchParams = sharedGlobalObject.URLSearchParams;
13
+
14
+ exports.parseURL = urlStateMachine.parseURL;
15
+ exports.basicURLParse = urlStateMachine.basicURLParse;
16
+ exports.serializeURL = urlStateMachine.serializeURL;
17
+ exports.serializePath = urlStateMachine.serializePath;
18
+ exports.serializeHost = urlStateMachine.serializeHost;
19
+ exports.serializeInteger = urlStateMachine.serializeInteger;
20
+ exports.serializeURLOrigin = urlStateMachine.serializeURLOrigin;
21
+ exports.setTheUsername = urlStateMachine.setTheUsername;
22
+ exports.setThePassword = urlStateMachine.setThePassword;
23
+ exports.cannotHaveAUsernamePasswordPort = urlStateMachine.cannotHaveAUsernamePasswordPort;
24
+ exports.hasAnOpaquePath = urlStateMachine.hasAnOpaquePath;
25
+
26
+ exports.percentDecodeString = percentEncoding.percentDecodeString;
27
+ exports.percentDecodeBytes = percentEncoding.percentDecodeBytes;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ const conversions = require("webidl-conversions");
4
+ const utils = require("./utils.js");
5
+
6
+ exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
7
+ if (typeof value !== "function") {
8
+ throw new globalObject.TypeError(context + " is not a function");
9
+ }
10
+
11
+ function invokeTheCallbackFunction(...args) {
12
+ const thisArg = utils.tryWrapperForImpl(this);
13
+ let callResult;
14
+
15
+ for (let i = 0; i < args.length; i++) {
16
+ args[i] = utils.tryWrapperForImpl(args[i]);
17
+ }
18
+
19
+ callResult = Reflect.apply(value, thisArg, args);
20
+
21
+ callResult = conversions["any"](callResult, { context: context, globals: globalObject });
22
+
23
+ return callResult;
24
+ }
25
+
26
+ invokeTheCallbackFunction.construct = (...args) => {
27
+ for (let i = 0; i < args.length; i++) {
28
+ args[i] = utils.tryWrapperForImpl(args[i]);
29
+ }
30
+
31
+ let callResult = Reflect.construct(value, args);
32
+
33
+ callResult = conversions["any"](callResult, { context: context, globals: globalObject });
34
+
35
+ return callResult;
36
+ };
37
+
38
+ invokeTheCallbackFunction[utils.wrapperSymbol] = value;
39
+ invokeTheCallbackFunction.objectReference = value;
40
+
41
+ return invokeTheCallbackFunction;
42
+ };
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ const usm = require("./url-state-machine");
3
+ const urlencoded = require("./urlencoded");
4
+ const URLSearchParams = require("./URLSearchParams");
5
+ const URL = require("./URL");
6
+
7
+ exports.implementation = class URLImpl {
8
+ // Unlike the spec, we duplicate some code between the constructor and canParse, because we want to give useful error
9
+ // messages in the constructor that distinguish between the different causes of failure.
10
+ constructor(globalObject, [url, base]) {
11
+ let parsedBase = null;
12
+ if (base !== undefined) {
13
+ parsedBase = usm.basicURLParse(base);
14
+ if (parsedBase === null) {
15
+ throw new TypeError(`Invalid base URL: ${base}`);
16
+ }
17
+ }
18
+
19
+ const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
20
+ if (parsedURL === null) {
21
+ throw new TypeError(`Invalid URL: ${url}`);
22
+ }
23
+
24
+ const query = parsedURL.query !== null ? parsedURL.query : "";
25
+
26
+ this._url = parsedURL;
27
+
28
+ // We cannot invoke the "new URLSearchParams object" algorithm without going through the constructor, which strips
29
+ // question mark by default. Therefore the doNotStripQMark hack is used.
30
+ this._query = URLSearchParams.createImpl(globalObject, [query], { doNotStripQMark: true });
31
+ this._query._url = this;
32
+ }
33
+
34
+ static parse(globalObject, input, base) {
35
+ try {
36
+ return URL.createImpl(globalObject, [input, base]);
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+
42
+ static canParse(url, base) {
43
+ let parsedBase = null;
44
+ if (base !== undefined) {
45
+ parsedBase = usm.basicURLParse(base);
46
+ if (parsedBase === null) {
47
+ return false;
48
+ }
49
+ }
50
+
51
+ const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
52
+ if (parsedURL === null) {
53
+ return false;
54
+ }
55
+
56
+ return true;
57
+ }
58
+
59
+ get href() {
60
+ return usm.serializeURL(this._url);
61
+ }
62
+
63
+ set href(v) {
64
+ const parsedURL = usm.basicURLParse(v);
65
+ if (parsedURL === null) {
66
+ throw new TypeError(`Invalid URL: ${v}`);
67
+ }
68
+
69
+ this._url = parsedURL;
70
+
71
+ this._query._list.splice(0);
72
+ const { query } = parsedURL;
73
+ if (query !== null) {
74
+ this._query._list = urlencoded.parseUrlencodedString(query);
75
+ }
76
+ }
77
+
78
+ get origin() {
79
+ return usm.serializeURLOrigin(this._url);
80
+ }
81
+
82
+ get protocol() {
83
+ return `${this._url.scheme}:`;
84
+ }
85
+
86
+ set protocol(v) {
87
+ usm.basicURLParse(`${v}:`, { url: this._url, stateOverride: "scheme start" });
88
+ }
89
+
90
+ get username() {
91
+ return this._url.username;
92
+ }
93
+
94
+ set username(v) {
95
+ if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
96
+ return;
97
+ }
98
+
99
+ usm.setTheUsername(this._url, v);
100
+ }
101
+
102
+ get password() {
103
+ return this._url.password;
104
+ }
105
+
106
+ set password(v) {
107
+ if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
108
+ return;
109
+ }
110
+
111
+ usm.setThePassword(this._url, v);
112
+ }
113
+
114
+ get host() {
115
+ const url = this._url;
116
+
117
+ if (url.host === null) {
118
+ return "";
119
+ }
120
+
121
+ if (url.port === null) {
122
+ return usm.serializeHost(url.host);
123
+ }
124
+
125
+ return `${usm.serializeHost(url.host)}:${usm.serializeInteger(url.port)}`;
126
+ }
127
+
128
+ set host(v) {
129
+ if (usm.hasAnOpaquePath(this._url)) {
130
+ return;
131
+ }
132
+
133
+ usm.basicURLParse(v, { url: this._url, stateOverride: "host" });
134
+ }
135
+
136
+ get hostname() {
137
+ if (this._url.host === null) {
138
+ return "";
139
+ }
140
+
141
+ return usm.serializeHost(this._url.host);
142
+ }
143
+
144
+ set hostname(v) {
145
+ if (usm.hasAnOpaquePath(this._url)) {
146
+ return;
147
+ }
148
+
149
+ usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" });
150
+ }
151
+
152
+ get port() {
153
+ if (this._url.port === null) {
154
+ return "";
155
+ }
156
+
157
+ return usm.serializeInteger(this._url.port);
158
+ }
159
+
160
+ set port(v) {
161
+ if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
162
+ return;
163
+ }
164
+
165
+ if (v === "") {
166
+ this._url.port = null;
167
+ } else {
168
+ usm.basicURLParse(v, { url: this._url, stateOverride: "port" });
169
+ }
170
+ }
171
+
172
+ get pathname() {
173
+ return usm.serializePath(this._url);
174
+ }
175
+
176
+ set pathname(v) {
177
+ if (usm.hasAnOpaquePath(this._url)) {
178
+ return;
179
+ }
180
+
181
+ this._url.path = [];
182
+ usm.basicURLParse(v, { url: this._url, stateOverride: "path start" });
183
+ }
184
+
185
+ get search() {
186
+ if (this._url.query === null || this._url.query === "") {
187
+ return "";
188
+ }
189
+
190
+ return `?${this._url.query}`;
191
+ }
192
+
193
+ set search(v) {
194
+ const url = this._url;
195
+
196
+ if (v === "") {
197
+ url.query = null;
198
+ this._query._list = [];
199
+ return;
200
+ }
201
+
202
+ const input = v[0] === "?" ? v.substring(1) : v;
203
+ url.query = "";
204
+ usm.basicURLParse(input, { url, stateOverride: "query" });
205
+ this._query._list = urlencoded.parseUrlencodedString(input);
206
+ }
207
+
208
+ get searchParams() {
209
+ return this._query;
210
+ }
211
+
212
+ get hash() {
213
+ if (this._url.fragment === null || this._url.fragment === "") {
214
+ return "";
215
+ }
216
+
217
+ return `#${this._url.fragment}`;
218
+ }
219
+
220
+ set hash(v) {
221
+ if (v === "") {
222
+ this._url.fragment = null;
223
+ return;
224
+ }
225
+
226
+ const input = v[0] === "#" ? v.substring(1) : v;
227
+ this._url.fragment = "";
228
+ usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" });
229
+ }
230
+
231
+ toJSON() {
232
+ return this.href;
233
+ }
234
+ };