Update base.py

This commit is contained in:
Namhyeon Go 2024-05-20 16:18:09 +09:00 committed by GitHub
parent 3360522dec
commit 6616832338
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

12
base.py
View File

@ -15,6 +15,18 @@ import json
client_encoding = 'utf-8'
def extract_credentials(url):
pattern = re.compile(r'(?P<scheme>\w+://)?(?P<username>[^:/]+):(?P<password>[^@]+)@(?P<url>.+)')
match = pattern.match(url)
if match:
scheme = match.group('scheme') if match.group('scheme') else 'https://'
username = match.group('username')
password = match.group('password')
url = match.group('url')
return username, password, scheme + url
else:
return None, None, url
def jsonrpc2_create_id(data):
return hashlib.sha1(json.dumps(data).encode(client_encoding)).hexdigest()