mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-08 11:18:28 +02:00
Improve error handling for auto tagging (#855)
This commit is contained in:
@@ -7,6 +7,9 @@ def get_tags(script: str, url: str):
|
|||||||
parsed_url = urlparse(url.lower())
|
parsed_url = urlparse(url.lower())
|
||||||
result = set()
|
result = set()
|
||||||
|
|
||||||
|
if not parsed_url.hostname:
|
||||||
|
return result
|
||||||
|
|
||||||
for line in script.lower().split("\n"):
|
for line in script.lower().split("\n"):
|
||||||
if "#" in line:
|
if "#" in line:
|
||||||
i = line.index("#")
|
i = line.index("#")
|
||||||
|
@@ -14,6 +14,20 @@ class AutoTaggingTestCase(TestCase):
|
|||||||
|
|
||||||
self.assertEqual(tags, {"example"})
|
self.assertEqual(tags, {"example"})
|
||||||
|
|
||||||
|
def test_auto_tag_by_domain_handles_invalid_urls(self):
|
||||||
|
script = """
|
||||||
|
example.com example
|
||||||
|
test.com test
|
||||||
|
"""
|
||||||
|
|
||||||
|
url = "https://"
|
||||||
|
tags = auto_tagging.get_tags(script, url)
|
||||||
|
self.assertEqual(tags, set([]))
|
||||||
|
|
||||||
|
url = "example.com"
|
||||||
|
tags = auto_tagging.get_tags(script, url)
|
||||||
|
self.assertEqual(tags, set([]))
|
||||||
|
|
||||||
def test_auto_tag_by_domain_works_with_port(self):
|
def test_auto_tag_by_domain_works_with_port(self):
|
||||||
script = """
|
script = """
|
||||||
example.com example
|
example.com example
|
||||||
|
Reference in New Issue
Block a user