match behavior of removeprefix

This commit is contained in:
Jonathan Metzman 2021-01-20 12:59:11 -08:00
parent 64aeebf94f
commit 63925e0e0d
1 changed files with 6 additions and 1 deletions

View File

@ -163,4 +163,9 @@ def gs_url_to_https(url):
def remove_prefix(string, prefix):
"""Returns |string| without the leading substring |prefix|."""
return string[len(prefix):]
# Match behavior of removeprefix from python3.9:
# https://www.python.org/dev/peps/pep-0616/
if string.startswith(prefix):
return string[len(prefix):]
return string