Merge pull request #126 from JinguBangWest/main

Refactor strip_web_protocol()
This commit is contained in:
Travis Abendshien
2024-05-03 17:59:32 -07:00
committed by GitHub

View File

@@ -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