change to string.removeprefix(prefix)

This commit is contained in:
JinguBangWest
2024-05-03 14:37:32 -04:00
parent bb1161baa9
commit 58c773a0de

View File

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