Fix auto-tagging when URL includes port (#820)

This commit is contained in:
Sascha Ißbrücker
2024-09-10 21:19:20 +02:00
committed by GitHub
parent cb0301fd9e
commit 7572aa5bc9
4 changed files with 57 additions and 36 deletions

View File

@@ -12,7 +12,18 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["example"]))
self.assertEqual(tags, {"example"})
def test_auto_tag_by_domain_works_with_port(self):
script = """
example.com example
test.com test
"""
url = "https://example.com:8080/"
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, {"example"})
def test_auto_tag_by_domain_ignores_case(self):
script = """
@@ -22,7 +33,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["example"]))
self.assertEqual(tags, {"example"})
def test_auto_tag_by_domain_should_add_all_tags(self):
script = """
@@ -32,7 +43,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["one", "two", "three"]))
self.assertEqual(tags, {"one", "two", "three"})
def test_auto_tag_by_domain_work_with_idn_domains(self):
script = """
@@ -42,7 +53,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["tag1"]))
self.assertEqual(tags, {"tag1"})
script = """
xn--81bg3cc2b2bk5hb.xn--h2brj9c tag1
@@ -51,7 +62,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["tag1"]))
self.assertEqual(tags, {"tag1"})
def test_auto_tag_by_domain_and_path(self):
script = """
@@ -63,7 +74,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["one"]))
self.assertEqual(tags, {"one"})
def test_auto_tag_by_domain_and_path_ignores_case(self):
script = """
@@ -73,7 +84,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["one"]))
self.assertEqual(tags, {"one"})
def test_auto_tag_by_domain_and_path_matches_path_ltr(self):
script = """
@@ -85,7 +96,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["one"]))
self.assertEqual(tags, {"one"})
def test_auto_tag_by_domain_ignores_domain_in_path(self):
script = """
@@ -107,7 +118,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["example", "test"]))
self.assertEqual(tags, {"example", "test"})
def test_auto_tag_by_domain_matches_domain_rtl(self):
script = """
@@ -128,7 +139,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["https", "http"]))
self.assertEqual(tags, {"https", "http"})
def test_auto_tag_by_domain_ignores_lines_with_no_tags(self):
script = """
@@ -154,7 +165,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["tag1", "tag2", "tag5", "tag6", "tag7"]))
self.assertEqual(tags, {"tag1", "tag2", "tag5", "tag6", "tag7"})
def test_auto_tag_by_domain_path_and_qs_with_empty_value(self):
script = """
@@ -165,7 +176,7 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["tag1"]))
self.assertEqual(tags, {"tag1"})
def test_auto_tag_by_domain_path_and_qs_works_with_encoded_url(self):
script = """
@@ -176,4 +187,4 @@ class AutoTaggingTestCase(TestCase):
tags = auto_tagging.get_tags(script, url)
self.assertEqual(tags, set(["tag1", "tag2"]))
self.assertEqual(tags, {"tag1", "tag2"})