From 76efba296f63f5da7c093d603f61e01015d98ddf Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 14 Feb 2018 20:08:14 +0100 Subject: [PATCH] urlmatch: Store path/port --- qutebrowser/utils/urlmatch.py | 9 ++++++++- tests/unit/utils/test_urlmatch.py | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/qutebrowser/utils/urlmatch.py b/qutebrowser/utils/urlmatch.py index f4385ee4d..43c7fa8c8 100644 --- a/qutebrowser/utils/urlmatch.py +++ b/qutebrowser/utils/urlmatch.py @@ -44,6 +44,8 @@ class UrlPattern: self._match_subdomains = False self._scheme = None self._host = None + self._path = None + self._port = None # > The special pattern matches any URL that starts with a # > permitted scheme. @@ -70,6 +72,7 @@ class UrlPattern: self._init_scheme(parsed) self._init_host(parsed) self._init_path(parsed) + self._init_port(parsed) def _init_scheme(self, parsed): if not parsed.scheme: @@ -79,9 +82,9 @@ class UrlPattern: self._scheme = parsed.scheme def _init_path(self, parsed): - # FIXME store somewhere if self._scheme == 'about' and not parsed.path.strip(): raise ValueError("Pattern without path") + self._path = parsed.path def _init_host(self, parsed): if self._scheme != 'about' and not parsed.netloc.strip(): @@ -95,5 +98,9 @@ class UrlPattern: # Only * or *.foo is allowed as host. raise ValueError("Invalid host wildcard") + def _init_port(self, parsed): + # FIXME validation? + self._port = parsed.port + def __repr__(self): return utils.get_repr(self, pattern=self._pattern, constructor=True) diff --git a/tests/unit/utils/test_urlmatch.py b/tests/unit/utils/test_urlmatch.py index fe7b9e9ed..de499aa87 100644 --- a/tests/unit/utils/test_urlmatch.py +++ b/tests/unit/utils/test_urlmatch.py @@ -50,8 +50,6 @@ from qutebrowser.utils import urlmatch ("http://foo.*.bar/baz", "Invalid host wildcard"), ("http://fo.*.ba:123/baz", "Invalid host wildcard"), ("http://foo.*/bar", "Invalid host wildcard"), - - # Some more tests ]) def test_invalid_patterns(pattern, error): with pytest.raises(ValueError, match=error):