Skip to content

Commit

Permalink
Change regex string to a raw string.
Browse files Browse the repository at this point in the history
  • Loading branch information
scheel authored and sigmavirus24 committed May 15, 2024
1 parent 04d7e27 commit 72ee030
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions twine/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ def _split_inputs(
return Inputs(dists, signatures, attestations_by_dist)


def _sanitize_url(url) -> str:
"""
def _sanitize_url(url: str) -> str:
"""Sanitize a URL.
Sanitize URLs, removing any user:password combinations and replacing them with
asterisks. Returns the original URL if the string is a non-matching pattern.
Expand All @@ -160,7 +161,7 @@ def _sanitize_url(url) -> str:
return:
str either sanitized or as entered depending on pattern match.
"""
pattern = "(.*https?://)(\w+:\w+)@(\w+\..*)"
pattern = r"(.*https?://)(\w+:\w+)@(\w+\..*)"
m = re.match(pattern, url)
if m:
newurl = f"{m.group(1)}*****:*****@{m.group(3)}"
Expand Down

0 comments on commit 72ee030

Please sign in to comment.