summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2018-03-06 09:45:06 +0100
committerFlorian Bruhin <git@the-compiler.org>2018-03-06 09:45:06 +0100
commit7fc53ae78ad8a41b5244924d6768b7249a694c78 (patch)
tree08d930bf279bb459c7f0d4ea735be0d3f88ce2a6
parentde3d2b1cb1f6afdd5a07027be7cf46be1a6f256c (diff)
downloadqutebrowser-7fc53ae78ad8a41b5244924d6768b7249a694c78.tar.gz
qutebrowser-7fc53ae78ad8a41b5244924d6768b7249a694c78.zip
Make path optional in URL patterns
See #3622
-rw-r--r--qutebrowser/utils/urlmatch.py5
-rw-r--r--tests/unit/utils/test_urlmatch.py10
2 files changed, 13 insertions, 2 deletions
diff --git a/qutebrowser/utils/urlmatch.py b/qutebrowser/utils/urlmatch.py
index 0e83c7420..fcddd0fe7 100644
--- a/qutebrowser/utils/urlmatch.py
+++ b/qutebrowser/utils/urlmatch.py
@@ -144,8 +144,9 @@ class UrlPattern:
if parsed.path == '/*':
self._path = None
elif parsed.path == '':
- # We want to make it possible to leave off a trailing slash.
- self._path = '/'
+ # When the user doesn't add a trailing slash, we assume the pattern
+ # matches any path.
+ self._path = None
else:
self._path = parsed.path
diff --git a/tests/unit/utils/test_urlmatch.py b/tests/unit/utils/test_urlmatch.py
index cb4e41767..88da166ca 100644
--- a/tests/unit/utils/test_urlmatch.py
+++ b/tests/unit/utils/test_urlmatch.py
@@ -112,6 +112,16 @@ def test_port(pattern, port):
assert up._port == port
+@pytest.mark.parametrize('pattern, path', [
+ ("http://foo/", '/'),
+ ("http://foo", None),
+ ("http://foo/*", None),
+])
+def test_parse_path(pattern, path):
+ up = urlmatch.UrlPattern(pattern)
+ assert up._path == path
+
+
class TestMatchAllPagesForGivenScheme:
@pytest.fixture