-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
892f1d6
commit 4a1d0da
Showing
3 changed files
with
13 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import urllib.parse | ||
|
||
def strip_url(url): | ||
return urllib.parse.urlparse(url).netloc | ||
"""This function strips the url from all parameters, usernames and passwords. | ||
It is used to safely log errors without exposing keys and authentication parameters.""" | ||
return urllib.parse.urlparse(url).hostname | ||
|
||
|
||
def url_join(url, path): | ||
return urllib.parse.urljoin(url, path) | ||
def url_join(url, target_path): | ||
"""Function takes url, and returns url + target path. This function also preserves | ||
all of the url parameters if they are present. | ||
This is important since different RPCs use different auth mechanisms (path or parameter)""" | ||
scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(url) | ||
path = path + target_path | ||
path = path.replace('//', '/') | ||
return urllib.parse.urlunparse((scheme, netloc, path, params, query, fragment)) |