Skip to content

Commit ac3d7c9

Browse files
authored
Merge pull request #126 from JinguBangWest/main
Refactor strip_web_protocol()
2 parents 64514db + 58c773a commit ac3d7c9

File tree

1 file changed

+4
-6
lines changed
  • tagstudio/src/core/utils

1 file changed

+4
-6
lines changed

tagstudio/src/core/utils/web.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

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

0 commit comments

Comments
 (0)