mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-21 19:03:02 +00:00
Improve error handling for auto tagging (#855)
This commit is contained in:
parent
c93709b549
commit
52400feacf
2 changed files with 17 additions and 0 deletions
|
@ -7,6 +7,9 @@ def get_tags(script: str, url: str):
|
|||
parsed_url = urlparse(url.lower())
|
||||
result = set()
|
||||
|
||||
if not parsed_url.hostname:
|
||||
return result
|
||||
|
||||
for line in script.lower().split("\n"):
|
||||
if "#" in line:
|
||||
i = line.index("#")
|
||||
|
|
|
@ -14,6 +14,20 @@ class AutoTaggingTestCase(TestCase):
|
|||
|
||||
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):
|
||||
script = """
|
||||
example.com example
|
||||
|
|
Loading…
Reference in a new issue