Skip to content

Commit

Permalink
Add in a check to remove trailing commas or slash characters from a URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Skptak committed Nov 8, 2023
1 parent d8787aa commit c48d7f8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion link-verifier/verify-links.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import traceback
from collections import defaultdict

MARKDOWN_SEARCH_TERM = r'\.md$'
MARKDOWN_SEARCH_TERM = r"\.md$"
# Regex to find a URL
URL_SEARCH_TERM = r'(\b(https?)://[^\s\)\]\\"<>]+[^\s\)\.\]\\"<>])'
HTTP_URL_SEARCH_TERM = r'https?://'
Expand Down Expand Up @@ -354,6 +354,9 @@ def main():
text = f.read()
urls = re.findall(URL_SEARCH_TERM, text)
for url in urls:
# Remove trailing comma or slash
if(url.endswith(',') or url.endswith('/')):
url[0] = url[0][:-1]
link_set.add(url[0])
link_to_files[url[0]].add(f_path)

Expand Down

0 comments on commit c48d7f8

Please sign in to comment.