@@ -3327,6 +3327,7 @@ are encouraged to use an API suitable to their needs, which might not be this on
3327
3327
interface URL {
3328
3328
constructor(USVString url, optional USVString base);
3329
3329
3330
+ static URL? parse(USVString url, optional USVString base);
3330
3331
static boolean canParse(USVString url, optional USVString base);
3331
3332
3332
3333
stringifier attribute USVString href;
@@ -3389,8 +3390,28 @@ null-or-<a>scalar value string</a> <var>base</var> (default null), and then runs
3389
3390
<var> parsedBase</var> .
3390
3391
</ol>
3391
3392
3393
+ <div algorithm>
3394
+ <p> To <dfn for=URL>initialize</dfn> a {{URL}} object <var> url</var> with a <a for=/>URL</var>
3395
+ <var>urlRecord</var>:
3396
+
3397
+ <li><p>Let <var>query</var> be <var>urlRecord</var>'s <a for=url>query</a> , if that is non-null;
3398
+ otherwise the empty string.
3399
+
3400
+ <li><p> Set <var> url</var> 's <a for=URL>URL</a> to <var> urlRecord</var> .
3401
+
3402
+ <li><p> Set <var> url</var> 's <a for=URL>query object</a> to a new {{URLSearchParams}} object.
3403
+
3404
+ <li><p> <a for=URLSearchParams>Initialize</a> <var> url</var> 's <a for=URL>query object</a> with
3405
+ <var> query</var> .
3406
+
3407
+ <li><p> Set <var> url</var> 's <a for=URL>query object</a>' s <a for=URLSearchParams>URL object</a> to
3408
+ <var> url</var> .
3409
+ </ol>
3410
+ </div>
3411
+
3392
3412
<hr>
3393
3413
3414
+ <div algorithm>
3394
3415
<p id=constructors> The
3395
3416
<dfn constructor for=URL lt="URL(url, base)"><code>new URL(<var>url</var>, <var>base</var>)</code></dfn>
3396
3417
constructor steps are:
@@ -3401,19 +3422,9 @@ constructor steps are:
3401
3422
3402
3423
<li><p> If <var> parsedURL</var> is failure, then <a>throw</a> a {{TypeError}} .
3403
3424
3404
- <li><p> Let <var> query</var> be <var> parsedURL</var> 's <a for=url>query</a> , if that is non-null,
3405
- and the empty string otherwise.
3406
-
3407
- <li><p> Set <a>this</a> 's <a for=URL>URL</a> to <var> parsedURL</var> .
3408
-
3409
- <li><p> Set <a>this</a> 's <a for=URL>query object</a> to a new {{URLSearchParams}} object.
3410
-
3411
- <li><p> <a for=URLSearchParams>Initialize</a> <a>this</a> 's <a for=URL>query object</a> with
3412
- <var> query</var> .
3413
-
3414
- <li><p> Set <a>this</a> 's <a for=URL>query object</a>' s <a for=URLSearchParams>URL object</a> to
3415
- <a>this</a> .
3425
+ <li><p> <a for=URL>Initialize</a> <a>this</a> with <var> parsedURL</var> .
3416
3426
</ol>
3427
+ </div>
3417
3428
3418
3429
<div class=example id=example-5434421b>
3419
3430
<p> To <a lt="basic URL parser">parse</a> a string into a <a for=/>URL</a> without using a
@@ -3450,6 +3461,24 @@ url.pathname // "/%F0%9F%8F%B3%EF%B8%8F%E2%80%8D%F0%9F%8C%88"</code></pre>
3450
3461
3451
3462
<hr>
3452
3463
3464
+ <div algorithm>
3465
+ <p> The static <dfn method for=URL><code>parse(<var>url</var>, <var>base</var>)</code></dfn> method
3466
+ steps are:
3467
+
3468
+ <ol>
3469
+ <li><p> Let <var> parsedURL</var> be the result of running the <a>API URL parser</a> on
3470
+ <var> url</var> with <var> base</var> , if given.
3471
+
3472
+ <li><p> If <var> parsedURL</var> is failure, then return null.
3473
+
3474
+ <li><p> Let <var> url</var> be a new <code> URL</code> object.
3475
+
3476
+ <li><p> <a for=URL>Initialize</a> <var> url</var> with <var> parsedURL</var> .
3477
+
3478
+ <li><p> Return <var> url</var> .
3479
+ </ol>
3480
+ </div>
3481
+
3453
3482
<p> The static <dfn method for=URL><code>canParse(<var>url</var>, <var>base</var>)</code></dfn>
3454
3483
method steps are:
3455
3484
0 commit comments