diff --git a/qutebrowser/utils/urlmatch.py b/qutebrowser/utils/urlmatch.py index c3fb5b599..b42e4249d 100644 --- a/qutebrowser/utils/urlmatch.py +++ b/qutebrowser/utils/urlmatch.py @@ -55,7 +55,7 @@ class UrlPattern: not file/ftp. We deviate from that as per-URL settings aren't security relevant. _host: The host to match to, or None for any host. - _path: The path to match to, or None for any path. (FIXME true?) + _path: The path to match to, or None for any path. _port: The port to match to as integer, or None for any port. """ @@ -124,7 +124,8 @@ class UrlPattern: def _init_path(self, parsed): if self._scheme == 'about' and not parsed.path.strip(): raise ParseError("Pattern without path") - self._path = parsed.path + + self._path = None if parsed.path == '/*' else parsed.path def _init_host(self, parsed): """Parse the host from the given URL. @@ -228,6 +229,9 @@ class UrlPattern: return self._port is None or self._port == port def _matches_path(self, path): + if self._path is None: + return True + # Match 'google.com' with 'google.com/' # FIXME use the no-copy approach Chromium has in URLPattern::MatchesPath # for performance? diff --git a/tests/unit/utils/test_urlmatch.py b/tests/unit/utils/test_urlmatch.py index 4220876e9..23ca58acc 100644 --- a/tests/unit/utils/test_urlmatch.py +++ b/tests/unit/utils/test_urlmatch.py @@ -107,7 +107,7 @@ class TestMatchAllPagesForGivenScheme: assert up._host is None assert up._match_subdomains assert not up._match_all - assert up._path == '/*' + assert up._path is None @pytest.mark.parametrize('url, expected', [ ("http://google.com", True), @@ -202,7 +202,7 @@ class TestMatchIpAddresses: assert up._host == host assert up._match_subdomains == match_subdomains assert not up._match_all - assert up._path == '/*' + assert up._path is None @pytest.mark.parametrize('pattern, expected', [ ("http://127.0.0.1/*", True), @@ -225,7 +225,7 @@ class TestMatchChromeUrls: assert up._host == 'favicon' assert not up._match_subdomains assert not up._match_all - assert up._path == '/*' + assert up._path is None @pytest.mark.parametrize('url, expected', [ ("chrome://favicon/http://google.com", True),