@oozcitak/url 1.0.4 → 2.0.1

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/lib/URLImpl.js CHANGED
@@ -1,30 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var URLSearchParamsImpl_1 = require("./URLSearchParamsImpl");
4
- var interfaces_1 = require("./interfaces");
5
- var URLAlgorithm_1 = require("./URLAlgorithm");
3
+ exports.URLImpl = void 0;
4
+ const URLSearchParamsImpl_1 = require("./URLSearchParamsImpl");
5
+ const interfaces_1 = require("./interfaces");
6
+ const URLAlgorithm_1 = require("./URLAlgorithm");
6
7
  /**
7
8
  * Represents an URL.
8
9
  */
9
- var URLImpl = /** @class */ (function () {
10
+ class URLImpl {
11
+ _url;
12
+ _queryObject;
10
13
  /**
11
14
  * Initializes a new `URL`.
12
15
  *
13
16
  * @param url - an URL string
14
17
  * @param base - a base URL string
15
18
  */
16
- function URLImpl(url, baseURL) {
19
+ constructor(url, baseURL) {
17
20
  /**
18
21
  * 1. Let parsedBase be null.
19
22
  * 2. If base is given, then:
20
23
  * 2.1. Let parsedBase be the result of running the basic URL parser on base.
21
24
  * 2.2. If parsedBase is failure, then throw a TypeError.
22
25
  */
23
- var parsedBase = null;
26
+ let parsedBase = null;
24
27
  if (baseURL !== undefined) {
25
- parsedBase = URLAlgorithm_1.basicURLParser(baseURL);
28
+ parsedBase = (0, URLAlgorithm_1.basicURLParser)(baseURL);
26
29
  if (parsedBase === null) {
27
- throw new TypeError("Invalid base URL: '" + baseURL + "'.");
30
+ throw new TypeError(`Invalid base URL: '${baseURL}'.`);
28
31
  }
29
32
  }
30
33
  /**
@@ -32,9 +35,9 @@ var URLImpl = /** @class */ (function () {
32
35
  * with parsedBase.
33
36
  * 4. If parsedURL is failure, then throw a TypeError.
34
37
  */
35
- var parsedURL = URLAlgorithm_1.basicURLParser(url, parsedBase);
38
+ const parsedURL = (0, URLAlgorithm_1.basicURLParser)(url, parsedBase);
36
39
  if (parsedURL === null) {
37
- throw new TypeError("Invalid URL: '" + url + "'.");
40
+ throw new TypeError(`Invalid URL: '${url}'.`);
38
41
  }
39
42
  /**
40
43
  * 5. Let query be parsedURL’s query, if that is non-null, and the empty
@@ -45,333 +48,284 @@ var URLImpl = /** @class */ (function () {
45
48
  * and then set that query object’s url object to result.
46
49
  * 9. Return result.
47
50
  */
48
- var query = parsedURL.query || "";
51
+ const query = parsedURL.query || "";
49
52
  this._url = parsedURL;
50
53
  this._queryObject = new URLSearchParamsImpl_1.URLSearchParamsImpl(query);
51
54
  this._queryObject._urlObject = this;
52
55
  }
53
- Object.defineProperty(URLImpl.prototype, "href", {
54
- /** @inheritdoc */
55
- get: function () {
56
- /**
57
- * The href attribute’s getter and the toJSON() method, when invoked, must
58
- * return the serialization of context object’s url.
59
- */
60
- return URLAlgorithm_1.urlSerializer(this._url);
61
- },
62
- set: function (value) {
63
- /**
64
- * 1. Let parsedURL be the result of running the basic URL parser on the
65
- * given value.
66
- * 2. If parsedURL is failure, then throw a TypeError.
67
- */
68
- var parsedURL = URLAlgorithm_1.basicURLParser(value);
69
- if (parsedURL === null) {
70
- throw new TypeError("Invalid URL: '" + value + "'.");
71
- }
72
- /**
73
- * 3. Set context object’s url to parsedURL.
74
- * 4. Empty context object’s query object’s list.
75
- * 5. Let query be context object’s url’s query.
76
- * 6. If query is non-null, then set context object’s query object’s list to
77
- * the result of parsing query.
78
- */
79
- this._url = parsedURL;
80
- this._queryObject._list = [];
81
- var query = this._url.query;
82
- if (query !== null) {
83
- this._queryObject._list = URLAlgorithm_1.urlEncodedStringParser(query);
84
- }
85
- },
86
- enumerable: true,
87
- configurable: true
88
- });
89
- Object.defineProperty(URLImpl.prototype, "origin", {
90
- /** @inheritdoc */
91
- get: function () {
92
- /**
93
- * The origin attribute’s getter must return the serialization of context
94
- * object’s url’s origin. [HTML]
95
- */
96
- return URLAlgorithm_1.asciiSerializationOfAnOrigin(URLAlgorithm_1.origin(this._url));
97
- },
98
- enumerable: true,
99
- configurable: true
100
- });
101
- Object.defineProperty(URLImpl.prototype, "protocol", {
102
- /** @inheritdoc */
103
- get: function () {
104
- /**
105
- * The protocol attribute’s getter must return context object url’s scheme,
106
- * followed by U+003A (:).
107
- */
108
- return this._url.scheme + ':';
109
- },
110
- set: function (val) {
111
- /**
112
- * The protocol attribute’s setter must basic URL parse the given value,
113
- * followed by U+003A (:), with context object’s url as url and scheme start
114
- * state as state override.
115
- */
116
- URLAlgorithm_1.basicURLParser(val + ':', undefined, undefined, this._url, interfaces_1.ParserState.SchemeStart);
117
- },
118
- enumerable: true,
119
- configurable: true
120
- });
121
- Object.defineProperty(URLImpl.prototype, "username", {
122
- /** @inheritdoc */
123
- get: function () {
124
- /**
125
- * The username attribute’s getter must return context object’s url’s
126
- * username.
127
- */
128
- return this._url.username;
129
- },
130
- set: function (val) {
131
- /**
132
- * 1. If context object’s url cannot have a username/password/port, then
133
- * return.
134
- * 2. Set the username given context object’s url and the given value.
135
- */
136
- if (URLAlgorithm_1.cannotHaveAUsernamePasswordPort(this._url))
137
- return;
138
- URLAlgorithm_1.setTheUsername(this._url, val);
139
- },
140
- enumerable: true,
141
- configurable: true
142
- });
143
- Object.defineProperty(URLImpl.prototype, "password", {
144
- /** @inheritdoc */
145
- get: function () {
146
- /**
147
- * The password attribute’s getter must return context object’s url’s
148
- * password.
149
- */
150
- return this._url.password;
151
- },
152
- set: function (val) {
153
- /**
154
- * 1. If context object’s url cannot have a username/password/port, then
155
- * return.
156
- * 2. Set the password given context object’s url and the given value.
157
- */
158
- if (URLAlgorithm_1.cannotHaveAUsernamePasswordPort(this._url))
159
- return;
160
- URLAlgorithm_1.setThePassword(this._url, val);
161
- },
162
- enumerable: true,
163
- configurable: true
164
- });
165
- Object.defineProperty(URLImpl.prototype, "host", {
166
- /** @inheritdoc */
167
- get: function () {
168
- /**
169
- * 1. Let url be context object’s url.
170
- * 2. If url’s host is null, return the empty string.
171
- * 3. If url’s port is null, return url’s host, serialized.
172
- * 4. Return url’s host, serialized, followed by U+003A (:) and url’s port,
173
- * serialized.
174
- */
175
- if (this._url.host === null) {
176
- return "";
177
- }
178
- else if (this._url.port === null) {
179
- return URLAlgorithm_1.hostSerializer(this._url.host);
180
- }
181
- else {
182
- return URLAlgorithm_1.hostSerializer(this._url.host) + ':' + this._url.port.toString();
183
- }
184
- },
185
- set: function (val) {
186
- /**
187
- * 1. If context object’s url’s cannot-be-a-base-URL flag is set, then
188
- * return.
189
- * 2. Basic URL parse the given value with context object’s url as url and
190
- * host state as state override.
191
- */
192
- if (this._url._cannotBeABaseURLFlag)
193
- return;
194
- URLAlgorithm_1.basicURLParser(val, undefined, undefined, this._url, interfaces_1.ParserState.Host);
195
- },
196
- enumerable: true,
197
- configurable: true
198
- });
199
- Object.defineProperty(URLImpl.prototype, "hostname", {
200
- /** @inheritdoc */
201
- get: function () {
202
- /**
203
- * 1. If context object’s url’s host is null, return the empty string.
204
- * 2. Return context object’s url’s host, serialized.
205
- */
206
- if (this._url.host === null)
207
- return "";
208
- return URLAlgorithm_1.hostSerializer(this._url.host);
209
- },
210
- set: function (val) {
211
- /**
212
- * 1. If context object’s url’s cannot-be-a-base-URL flag is set, then
213
- * return.
214
- * 2. Basic URL parse the given value with context object’s url as url and
215
- * hostname state as state override.
216
- */
217
- if (this._url._cannotBeABaseURLFlag)
218
- return;
219
- URLAlgorithm_1.basicURLParser(val, undefined, undefined, this._url, interfaces_1.ParserState.Hostname);
220
- },
221
- enumerable: true,
222
- configurable: true
223
- });
224
- Object.defineProperty(URLImpl.prototype, "port", {
225
- /** @inheritdoc */
226
- get: function () {
227
- /**
228
- * 1. If context object’s url’s port is null, return the empty string.
229
- * 2. Return context object’s url’s port, serialized.
230
- */
231
- if (this._url.port === null)
232
- return "";
233
- return this._url.port.toString();
234
- },
235
- set: function (val) {
236
- /**
237
- * 1. If context object’s url cannot have a username/password/port, then
238
- * return.
239
- * 2. If the given value is the empty string, then set context object’s
240
- * url’s port to null.
241
- * 3. Otherwise, basic URL parse the given value with context object’s url
242
- * as url and port state as state override.
243
- */
244
- if (URLAlgorithm_1.cannotHaveAUsernamePasswordPort(this._url))
245
- return;
246
- if (val === "") {
247
- this._url.port = null;
248
- }
249
- else {
250
- URLAlgorithm_1.basicURLParser(val, undefined, undefined, this._url, interfaces_1.ParserState.Port);
251
- }
252
- },
253
- enumerable: true,
254
- configurable: true
255
- });
256
- Object.defineProperty(URLImpl.prototype, "pathname", {
257
- /** @inheritdoc */
258
- get: function () {
259
- /**
260
- * 1. If context object’s url’s cannot-be-a-base-URL flag is set, then
261
- * return context object’s url’s path[0].
262
- * 2. If context object’s url’s path is empty, then return the empty string.
263
- * 3. Return U+002F (/), followed by the strings in context object’s url’s
264
- * path (including empty strings), if any, separated from each other by
265
- * U+002F (/).
266
- */
267
- if (this._url._cannotBeABaseURLFlag)
268
- return this._url.path[0];
269
- if (this._url.path.length === 0)
270
- return "";
271
- return '/' + this._url.path.join('/');
272
- },
273
- set: function (val) {
274
- /**
275
- * 1. If context object’s url’s cannot-be-a-base-URL flag is set, then return.
276
- * 2. Empty context object’s url’s path.
277
- * 3. Basic URL parse the given value with context object’s url as url and
278
- * path start state as state override.
279
- */
280
- if (this._url._cannotBeABaseURLFlag)
281
- return;
282
- this._url.path = [];
283
- URLAlgorithm_1.basicURLParser(val, undefined, undefined, this._url, interfaces_1.ParserState.PathStart);
284
- },
285
- enumerable: true,
286
- configurable: true
287
- });
288
- Object.defineProperty(URLImpl.prototype, "search", {
289
- /** @inheritdoc */
290
- get: function () {
291
- /**
292
- * 1. If context object’s url’s query is either null or the empty string,
293
- * return the empty string.
294
- * 2. Return U+003F (?), followed by context object’s url’s query.
295
- */
296
- if (this._url.query === null || this._url.query === "")
297
- return "";
298
- return '?' + this._url.query;
299
- },
300
- set: function (val) {
301
- /**
302
- * 1. Let url be context object’s url.
303
- * 2. If the given value is the empty string, set url’s query to null,
304
- * empty context object’s query object’s list, and then return.
305
- * 3. Let input be the given value with a single leading U+003F (?) removed,
306
- * if any.
307
- * 4. Set url’s query to the empty string.
308
- * 5. Basic URL parse input with url as url and query state as state
309
- * override.
310
- * 6. Set context object’s query object’s list to the result of parsing
311
- * input.
312
- */
313
- var url = this._url;
314
- if (val === "") {
315
- url.query = null;
316
- this._queryObject._list.length = 0;
317
- return;
318
- }
319
- if (val.startsWith('?'))
320
- val = val.substr(1);
321
- url.query = "";
322
- URLAlgorithm_1.basicURLParser(val, undefined, undefined, url, interfaces_1.ParserState.Query);
323
- this._queryObject._list = URLAlgorithm_1.urlEncodedStringParser(val);
324
- },
325
- enumerable: true,
326
- configurable: true
327
- });
328
- Object.defineProperty(URLImpl.prototype, "searchParams", {
329
- /** @inheritdoc */
330
- get: function () { return this._queryObject; },
331
- enumerable: true,
332
- configurable: true
333
- });
334
- Object.defineProperty(URLImpl.prototype, "hash", {
335
- /** @inheritdoc */
336
- get: function () {
337
- /**
338
- * 1. If context object’s url’s fragment is either null or the empty string,
339
- * return the empty string.
340
- * 2. Return U+0023 (#), followed by context object’s url’s fragment.
341
- */
342
- if (this._url.fragment === null || this._url.fragment === "")
343
- return "";
344
- return '#' + this._url.fragment;
345
- },
346
- set: function (val) {
347
- /**
348
- * 1. If the given value is the empty string, then set context object’s
349
- * url’s fragment to null and return.
350
- * 2. Let input be the given value with a single leading U+0023 (#) removed,
351
- * if any.
352
- * 3. Set context object’s url’s fragment to the empty string.
353
- * 4. Basic URL parse input with context object’s url as url and fragment
354
- * state as state override.
355
- */
356
- if (val === "") {
357
- this._url.fragment = null;
358
- return;
359
- }
360
- if (val.startsWith('#'))
361
- val = val.substr(1);
362
- this._url.fragment = "";
363
- URLAlgorithm_1.basicURLParser(val, undefined, undefined, this._url, interfaces_1.ParserState.Fragment);
364
- },
365
- enumerable: true,
366
- configurable: true
367
- });
368
56
  /** @inheritdoc */
369
- URLImpl.prototype.toJSON = function () { return URLAlgorithm_1.urlSerializer(this._url); };
57
+ get href() {
58
+ /**
59
+ * The href attribute’s getter and the toJSON() method, when invoked, must
60
+ * return the serialization of context object’s url.
61
+ */
62
+ return (0, URLAlgorithm_1.urlSerializer)(this._url);
63
+ }
64
+ set href(value) {
65
+ /**
66
+ * 1. Let parsedURL be the result of running the basic URL parser on the
67
+ * given value.
68
+ * 2. If parsedURL is failure, then throw a TypeError.
69
+ */
70
+ const parsedURL = (0, URLAlgorithm_1.basicURLParser)(value);
71
+ if (parsedURL === null) {
72
+ throw new TypeError(`Invalid URL: '${value}'.`);
73
+ }
74
+ /**
75
+ * 3. Set context object’s url to parsedURL.
76
+ * 4. Empty context object’s query object’s list.
77
+ * 5. Let query be context object’s url’s query.
78
+ * 6. If query is non-null, then set context object’s query object’s list to
79
+ * the result of parsing query.
80
+ */
81
+ this._url = parsedURL;
82
+ this._queryObject._list = [];
83
+ const query = this._url.query;
84
+ if (query !== null) {
85
+ this._queryObject._list = (0, URLAlgorithm_1.urlEncodedStringParser)(query);
86
+ }
87
+ }
88
+ /** @inheritdoc */
89
+ get origin() {
90
+ /**
91
+ * The origin attribute’s getter must return the serialization of context
92
+ * object’s url’s origin. [HTML]
93
+ */
94
+ return (0, URLAlgorithm_1.asciiSerializationOfAnOrigin)((0, URLAlgorithm_1.origin)(this._url));
95
+ }
96
+ /** @inheritdoc */
97
+ get protocol() {
98
+ /**
99
+ * The protocol attribute’s getter must return context object url’s scheme,
100
+ * followed by U+003A (:).
101
+ */
102
+ return this._url.scheme + ':';
103
+ }
104
+ set protocol(val) {
105
+ /**
106
+ * The protocol attribute’s setter must basic URL parse the given value,
107
+ * followed by U+003A (:), with context object’s url as url and scheme start
108
+ * state as state override.
109
+ */
110
+ (0, URLAlgorithm_1.basicURLParser)(val + ':', undefined, undefined, this._url, interfaces_1.ParserState.SchemeStart);
111
+ }
112
+ /** @inheritdoc */
113
+ get username() {
114
+ /**
115
+ * The username attribute’s getter must return context object’s url’s
116
+ * username.
117
+ */
118
+ return this._url.username;
119
+ }
120
+ set username(val) {
121
+ /**
122
+ * 1. If context object’s url cannot have a username/password/port, then
123
+ * return.
124
+ * 2. Set the username given context object’s url and the given value.
125
+ */
126
+ if ((0, URLAlgorithm_1.cannotHaveAUsernamePasswordPort)(this._url))
127
+ return;
128
+ (0, URLAlgorithm_1.setTheUsername)(this._url, val);
129
+ }
130
+ /** @inheritdoc */
131
+ get password() {
132
+ /**
133
+ * The password attribute’s getter must return context object’s url’s
134
+ * password.
135
+ */
136
+ return this._url.password;
137
+ }
138
+ set password(val) {
139
+ /**
140
+ * 1. If context object’s url cannot have a username/password/port, then
141
+ * return.
142
+ * 2. Set the password given context object’s url and the given value.
143
+ */
144
+ if ((0, URLAlgorithm_1.cannotHaveAUsernamePasswordPort)(this._url))
145
+ return;
146
+ (0, URLAlgorithm_1.setThePassword)(this._url, val);
147
+ }
148
+ /** @inheritdoc */
149
+ get host() {
150
+ /**
151
+ * 1. Let url be context object’s url.
152
+ * 2. If url’s host is null, return the empty string.
153
+ * 3. If url’s port is null, return url’s host, serialized.
154
+ * 4. Return url’s host, serialized, followed by U+003A (:) and url’s port,
155
+ * serialized.
156
+ */
157
+ if (this._url.host === null) {
158
+ return "";
159
+ }
160
+ else if (this._url.port === null) {
161
+ return (0, URLAlgorithm_1.hostSerializer)(this._url.host);
162
+ }
163
+ else {
164
+ return (0, URLAlgorithm_1.hostSerializer)(this._url.host) + ':' + this._url.port.toString();
165
+ }
166
+ }
167
+ set host(val) {
168
+ /**
169
+ * 1. If context object’s url’s cannot-be-a-base-URL flag is set, then
170
+ * return.
171
+ * 2. Basic URL parse the given value with context object’s url as url and
172
+ * host state as state override.
173
+ */
174
+ if (this._url._cannotBeABaseURLFlag)
175
+ return;
176
+ (0, URLAlgorithm_1.basicURLParser)(val, undefined, undefined, this._url, interfaces_1.ParserState.Host);
177
+ }
178
+ /** @inheritdoc */
179
+ get hostname() {
180
+ /**
181
+ * 1. If context object’s url’s host is null, return the empty string.
182
+ * 2. Return context object’s url’s host, serialized.
183
+ */
184
+ if (this._url.host === null)
185
+ return "";
186
+ return (0, URLAlgorithm_1.hostSerializer)(this._url.host);
187
+ }
188
+ set hostname(val) {
189
+ /**
190
+ * 1. If context object’s url’s cannot-be-a-base-URL flag is set, then
191
+ * return.
192
+ * 2. Basic URL parse the given value with context object’s url as url and
193
+ * hostname state as state override.
194
+ */
195
+ if (this._url._cannotBeABaseURLFlag)
196
+ return;
197
+ (0, URLAlgorithm_1.basicURLParser)(val, undefined, undefined, this._url, interfaces_1.ParserState.Hostname);
198
+ }
199
+ /** @inheritdoc */
200
+ get port() {
201
+ /**
202
+ * 1. If context object’s url’s port is null, return the empty string.
203
+ * 2. Return context object’s url’s port, serialized.
204
+ */
205
+ if (this._url.port === null)
206
+ return "";
207
+ return this._url.port.toString();
208
+ }
209
+ set port(val) {
210
+ /**
211
+ * 1. If context object’s url cannot have a username/password/port, then
212
+ * return.
213
+ * 2. If the given value is the empty string, then set context object’s
214
+ * url’s port to null.
215
+ * 3. Otherwise, basic URL parse the given value with context object’s url
216
+ * as url and port state as state override.
217
+ */
218
+ if ((0, URLAlgorithm_1.cannotHaveAUsernamePasswordPort)(this._url))
219
+ return;
220
+ if (val === "") {
221
+ this._url.port = null;
222
+ }
223
+ else {
224
+ (0, URLAlgorithm_1.basicURLParser)(val, undefined, undefined, this._url, interfaces_1.ParserState.Port);
225
+ }
226
+ }
370
227
  /** @inheritdoc */
371
- URLImpl.prototype.toString = function () {
228
+ get pathname() {
229
+ /**
230
+ * 1. If context object’s url’s cannot-be-a-base-URL flag is set, then
231
+ * return context object’s url’s path[0].
232
+ * 2. If context object’s url’s path is empty, then return the empty string.
233
+ * 3. Return U+002F (/), followed by the strings in context object’s url’s
234
+ * path (including empty strings), if any, separated from each other by
235
+ * U+002F (/).
236
+ */
237
+ if (this._url._cannotBeABaseURLFlag)
238
+ return this._url.path[0];
239
+ if (this._url.path.length === 0)
240
+ return "";
241
+ return '/' + this._url.path.join('/');
242
+ }
243
+ set pathname(val) {
244
+ /**
245
+ * 1. If context object’s url’s cannot-be-a-base-URL flag is set, then return.
246
+ * 2. Empty context object’s url’s path.
247
+ * 3. Basic URL parse the given value with context object’s url as url and
248
+ * path start state as state override.
249
+ */
250
+ if (this._url._cannotBeABaseURLFlag)
251
+ return;
252
+ this._url.path = [];
253
+ (0, URLAlgorithm_1.basicURLParser)(val, undefined, undefined, this._url, interfaces_1.ParserState.PathStart);
254
+ }
255
+ /** @inheritdoc */
256
+ get search() {
257
+ /**
258
+ * 1. If context object’s url’s query is either null or the empty string,
259
+ * return the empty string.
260
+ * 2. Return U+003F (?), followed by context object’s url’s query.
261
+ */
262
+ if (this._url.query === null || this._url.query === "")
263
+ return "";
264
+ return '?' + this._url.query;
265
+ }
266
+ set search(val) {
267
+ /**
268
+ * 1. Let url be context object’s url.
269
+ * 2. If the given value is the empty string, set url’s query to null,
270
+ * empty context object’s query object’s list, and then return.
271
+ * 3. Let input be the given value with a single leading U+003F (?) removed,
272
+ * if any.
273
+ * 4. Set url’s query to the empty string.
274
+ * 5. Basic URL parse input with url as url and query state as state
275
+ * override.
276
+ * 6. Set context object’s query object’s list to the result of parsing
277
+ * input.
278
+ */
279
+ const url = this._url;
280
+ if (val === "") {
281
+ url.query = null;
282
+ this._queryObject._list.length = 0;
283
+ return;
284
+ }
285
+ if (val.startsWith('?'))
286
+ val = val.substr(1);
287
+ url.query = "";
288
+ (0, URLAlgorithm_1.basicURLParser)(val, undefined, undefined, url, interfaces_1.ParserState.Query);
289
+ this._queryObject._list = (0, URLAlgorithm_1.urlEncodedStringParser)(val);
290
+ }
291
+ /** @inheritdoc */
292
+ get searchParams() { return this._queryObject; }
293
+ /** @inheritdoc */
294
+ get hash() {
295
+ /**
296
+ * 1. If context object’s url’s fragment is either null or the empty string,
297
+ * return the empty string.
298
+ * 2. Return U+0023 (#), followed by context object’s url’s fragment.
299
+ */
300
+ if (this._url.fragment === null || this._url.fragment === "")
301
+ return "";
302
+ return '#' + this._url.fragment;
303
+ }
304
+ set hash(val) {
305
+ /**
306
+ * 1. If the given value is the empty string, then set context object’s
307
+ * url’s fragment to null and return.
308
+ * 2. Let input be the given value with a single leading U+0023 (#) removed,
309
+ * if any.
310
+ * 3. Set context object’s url’s fragment to the empty string.
311
+ * 4. Basic URL parse input with context object’s url as url and fragment
312
+ * state as state override.
313
+ */
314
+ if (val === "") {
315
+ this._url.fragment = null;
316
+ return;
317
+ }
318
+ if (val.startsWith('#'))
319
+ val = val.substr(1);
320
+ this._url.fragment = "";
321
+ (0, URLAlgorithm_1.basicURLParser)(val, undefined, undefined, this._url, interfaces_1.ParserState.Fragment);
322
+ }
323
+ /** @inheritdoc */
324
+ toJSON() { return (0, URLAlgorithm_1.urlSerializer)(this._url); }
325
+ /** @inheritdoc */
326
+ toString() {
372
327
  return this.href;
373
- };
374
- return URLImpl;
375
- }());
328
+ }
329
+ }
376
330
  exports.URLImpl = URLImpl;
377
331
  //# sourceMappingURL=URLImpl.js.map