Auto-add protocol to URLs that do not have one. Fixes #54
This commit is contained in:
pare
996219c1c8
commit
df98fc263e
S'han modificat 1 arxius amb 9 adicions i 1 eliminacions
|
@ -44,6 +44,7 @@ class Mastodon:
|
||||||
|
|
||||||
Returns client_id and client_secret.
|
Returns client_id and client_secret.
|
||||||
"""
|
"""
|
||||||
|
api_base_url = Mastodon.__protocolize(api_base_url)
|
||||||
|
|
||||||
request_data = {
|
request_data = {
|
||||||
'client_name': client_name,
|
'client_name': client_name,
|
||||||
|
@ -95,7 +96,7 @@ class Mastodon:
|
||||||
By default, a timeout of 300 seconds is used for all requests. If you wish to change this,
|
By default, a timeout of 300 seconds is used for all requests. If you wish to change this,
|
||||||
pass the desired timeout (in seconds) as request_timeout.
|
pass the desired timeout (in seconds) as request_timeout.
|
||||||
"""
|
"""
|
||||||
self.api_base_url = api_base_url
|
self.api_base_url = Mastodon.__protocolize(api_base_url)
|
||||||
self.client_id = client_id
|
self.client_id = client_id
|
||||||
self.client_secret = client_secret
|
self.client_secret = client_secret
|
||||||
self.access_token = access_token
|
self.access_token = access_token
|
||||||
|
@ -977,6 +978,13 @@ class Mastodon:
|
||||||
self._refresh_token = value
|
self._refresh_token = value
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def __protocolize(base_url):
|
||||||
|
"""Internal add-protocol-to-url helper"""
|
||||||
|
if not base_url.startswith("http://") and not base_url.startswith("https://"):
|
||||||
|
base_url = "https://" + base_url
|
||||||
|
return base_url
|
||||||
|
|
||||||
##
|
##
|
||||||
# Exceptions
|
# Exceptions
|
||||||
##
|
##
|
||||||
|
|
Loading…
Referencia en una nova incidència