Skip to content

Commit

Permalink
URLPattern: Support username:password@ in constructor strings.
Browse files Browse the repository at this point in the history
This adds support to for specifying a username and password pattern in
the constructor string.  While this is unlikely to be used frequently
it was added to complete support for all URL components.

This CL also adds a class comment for the `Parser` which was forgotten
in previous CLs.

Bug: 1141510
Change-Id: I984db6224b1fd36390a21c241d204573ed50d78d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2937293
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/master@{#892269}
  • Loading branch information
wanderview authored and chromium-wpt-export-bot committed Jun 14, 2021
1 parent ca6913e commit 9fc2678
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions urlpattern/resources/urlpatterntestdata.json
Expand Up @@ -1951,5 +1951,110 @@
"pathname": { "input": "/foo", "groups": {} },
"hash": { "input": "baz", "groups": {} }
}
},
{
"pattern": [ "https://foo\\:bar@example.com" ],
"inputs": [ "https://foo:bar@example.com" ],
"exactly_empty_components": [ "port", "search", "hash" ],
"expected_obj": {
"protocol": "https",
"username": "foo",
"password": "bar",
"hostname": "example.com",
"pathname": "/"
},
"expected_match": {
"protocol": { "input": "https", "groups": {} },
"username": { "input": "foo", "groups": {} },
"password": { "input": "bar", "groups": {} },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": {} }
}
},
{
"pattern": [ "https://foo@example.com" ],
"inputs": [ "https://foo@example.com" ],
"exactly_empty_components": [ "password", "port", "search", "hash" ],
"expected_obj": {
"protocol": "https",
"username": "foo",
"hostname": "example.com",
"pathname": "/"
},
"expected_match": {
"protocol": { "input": "https", "groups": {} },
"username": { "input": "foo", "groups": {} },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": {} }
}
},
{
"pattern": [ "https://\\:bar@example.com" ],
"inputs": [ "https://:bar@example.com" ],
"exactly_empty_components": [ "username", "port", "search", "hash" ],
"expected_obj": {
"protocol": "https",
"password": "bar",
"hostname": "example.com",
"pathname": "/"
},
"expected_match": {
"protocol": { "input": "https", "groups": {} },
"password": { "input": "bar", "groups": {} },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": {} }
}
},
{
"pattern": [ "https://:user::pass@example.com" ],
"inputs": [ "https://foo:bar@example.com" ],
"exactly_empty_components": [ "port", "search", "hash" ],
"expected_obj": {
"protocol": "https",
"username": ":user",
"password": ":pass",
"hostname": "example.com",
"pathname": "/"
},
"expected_match": {
"protocol": { "input": "https", "groups": {} },
"username": { "input": "foo", "groups": { "user": "foo" } },
"password": { "input": "bar", "groups": { "pass": "bar" } },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": {} }
}
},
{
"pattern": [ "https\\:foo\\:bar@example.com" ],
"inputs": [ "https:foo:bar@example.com" ],
"exactly_empty_components": [ "port", "search", "hash" ],
"expected_obj": {
"protocol": "https",
"username": "foo",
"password": "bar",
"hostname": "example.com",
"pathname": "/"
},
"expected_match": {
"protocol": { "input": "https", "groups": {} },
"username": { "input": "foo", "groups": {} },
"password": { "input": "bar", "groups": {} },
"hostname": { "input": "example.com", "groups": {} },
"pathname": { "input": "/", "groups": {} }
}
},
{
"pattern": [ "data\\:foo\\:bar@example.com" ],
"inputs": [ "data:foo:bar@example.com" ],
"exactly_empty_components": [ "username", "password", "hostname", "port",
"search", "hash" ],
"expected_obj": {
"protocol": "data",
"pathname": "foo\\:bar@example.com"
},
"expected_match": {
"protocol": { "input": "data", "groups": {} },
"pathname": { "input": "foo:bar@example.com", "groups": {} }
}
}
]

0 comments on commit 9fc2678

Please sign in to comment.