mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-14 05:59:29 +02:00
Allow auto tagging rules to match URL fragments (#1045)
This commit is contained in:
@@ -202,3 +202,44 @@ class AutoTaggingTestCase(TestCase):
|
||||
tags = auto_tagging.get_tags(script, url)
|
||||
|
||||
self.assertEqual(tags, {"tag1", "tag2"})
|
||||
|
||||
def test_auto_tag_with_url_fragment(self):
|
||||
script = """
|
||||
example.com/#/section/1 section1
|
||||
example.com/#/section/2 section2
|
||||
"""
|
||||
url = "https://example.com/#/section/1"
|
||||
|
||||
tags = auto_tagging.get_tags(script, url)
|
||||
|
||||
self.assertEqual(tags, {"section1"})
|
||||
|
||||
def test_auto_tag_with_url_fragment_partial_match(self):
|
||||
script = """
|
||||
example.com/#/section section
|
||||
"""
|
||||
url = "https://example.com/#/section/1"
|
||||
|
||||
tags = auto_tagging.get_tags(script, url)
|
||||
|
||||
self.assertEqual(tags, {"section"})
|
||||
|
||||
def test_auto_tag_with_url_fragment_ignores_case(self):
|
||||
script = """
|
||||
example.com/#SECTION section
|
||||
"""
|
||||
url = "https://example.com/#section"
|
||||
|
||||
tags = auto_tagging.get_tags(script, url)
|
||||
|
||||
self.assertEqual(tags, {"section"})
|
||||
|
||||
def test_auto_tag_with_url_fragment_and_comment(self):
|
||||
script = """
|
||||
example.com/#section1 section1 #This is a comment
|
||||
"""
|
||||
url = "https://example.com/#section1"
|
||||
|
||||
tags = auto_tagging.get_tags(script, url)
|
||||
|
||||
self.assertEqual(tags, {"section1"})
|
||||
|
Reference in New Issue
Block a user