Skip to content

Commit

Permalink
Merge pull request #126 from JinguBangWest/main
Browse files Browse the repository at this point in the history
Refactor strip_web_protocol()
  • Loading branch information
CyanVoxel committed May 4, 2024
2 parents 64514db + 58c773a commit ac3d7c9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tagstudio/src/core/utils/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

def strip_web_protocol(string: str) -> str:
"""Strips a leading web protocol (ex. \"https://\") as well as \"www.\" from a string."""
new_str = string
new_str = new_str.removeprefix('https://')
new_str = new_str.removeprefix('http://')
new_str = new_str.removeprefix('www.')
new_str = new_str.removeprefix('www2.')
return new_str
prefixes = ['https://','http://','www.','www2.']
for prefix in prefixes:
string = string.removeprefix(prefix)
return string

0 comments on commit ac3d7c9

Please sign in to comment.