From 8bd7648f8745be7881f4c606868d3314f002355f Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Thu, 2 Sep 2021 09:16:17 -0700 Subject: [PATCH] URLPattern: Support constructor strings with ipv6 addresses. This adds support for constructor strings like: new URLPattern("http://[\\:\\:1]/"); As discussed in spec issue #113: https://github.com/WICG/urlpattern/issues/113 Fixed: 1245760 Change-Id: I712341e72a5c2af745dbbdbb8673a79809a98425 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3138336 Commit-Queue: Ben Kelly Reviewed-by: Jeremy Roman Cr-Commit-Position: refs/heads/main@{#917682} --- urlpattern/resources/urlpatterntestdata.json | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/urlpattern/resources/urlpatterntestdata.json b/urlpattern/resources/urlpatterntestdata.json index e9967adf219778..5ef045e560acb5 100644 --- a/urlpattern/resources/urlpatterntestdata.json +++ b/urlpattern/resources/urlpatterntestdata.json @@ -2150,6 +2150,55 @@ "pathname": { "input": "/data:channel.html", "groups": {} } } }, + { + "pattern": [ "http://[\\:\\:1]/" ], + "inputs": [ "http://[::1]/" ], + "exactly_empty_components": [ "username", "password", "port", "search", + "hash" ], + "expected_obj": { + "protocol": "http", + "hostname": "[\\:\\:1]", + "pathname": "/" + }, + "expected_match": { + "protocol": { "input": "http", "groups": {} }, + "hostname": { "input": "[::1]", "groups": {} }, + "pathname": { "input": "/", "groups": {} } + } + }, + { + "pattern": [ "http://[\\:\\:1]:8080/" ], + "inputs": [ "http://[::1]:8080/" ], + "exactly_empty_components": [ "username", "password", "search", "hash" ], + "expected_obj": { + "protocol": "http", + "hostname": "[\\:\\:1]", + "port": "8080", + "pathname": "/" + }, + "expected_match": { + "protocol": { "input": "http", "groups": {} }, + "hostname": { "input": "[::1]", "groups": {} }, + "port": { "input": "8080", "groups": {} }, + "pathname": { "input": "/", "groups": {} } + } + }, + { + "pattern": [ "http://[\\:\\:a]/" ], + "inputs": [ "http://[::a]/" ], + "exactly_empty_components": [ "username", "password", "port", "search", + "hash" ], + "expected_obj": { + "protocol": "http", + "hostname": "[\\:\\:a]", + "pathname": "/" + }, + "expected_match": { + "protocol": { "input": "http", "groups": {} }, + "hostname": { "input": "[::a]", "groups": {} }, + "pathname": { "input": "/", "groups": {} } + } + }, { "pattern": [ "https://foo{{@}}example.com" ], "inputs": [ "https://foo@example.com" ],