Skip to content

Commit 86c8dc4

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
authored andcommitted
diactric fix
1 parent f391379 commit 86c8dc4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

imagekitio/url.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def build_url(self, options: dict) -> str:
8585
private_key = options.get("private_key")
8686
expiry_timestamp = self.get_signature_timestamp(expire_seconds)
8787
url_signature = self.get_signature(
88-
self,
8988
private_key=private_key,
9089
url=url_object.geturl(),
9190
url_endpoint=url_endpoint,
@@ -130,11 +129,11 @@ def get_signature_timestamp(expiry_seconds: int = None) -> int:
130129
return current_timestamp + expiry_seconds
131130

132131
@staticmethod
133-
def get_signature(self, private_key, url, url_endpoint, expiry_timestamp: int) -> str:
132+
def get_signature(private_key, url, url_endpoint, expiry_timestamp: int) -> str:
134133
last_slash_pos = url.rfind('/')
135134
question_mark_pos = url.find('?', last_slash_pos)
136135
path = url[last_slash_pos + 1:question_mark_pos] if question_mark_pos != -1 else url[last_slash_pos + 1:]
137-
encoded_path = self.encode_string_if_required(self,path)
136+
encoded_path = Url.encode_string_if_required(path)
138137
encoded_url = url[:last_slash_pos + 1] + encoded_path + url[question_mark_pos:] if question_mark_pos != -1 else url[:last_slash_pos + 1] + encoded_path
139138
url = encoded_url
140139
print(url)
@@ -225,5 +224,5 @@ def has_more_than_ascii(s):
225224
return any(ord(char) > 127 for char in s)
226225

227226
@staticmethod
228-
def encode_string_if_required(self,s):
229-
return quote(s) if self.has_more_than_ascii(s) else s
227+
def encode_string_if_required(s):
228+
return quote(s) if Url.has_more_than_ascii(s) else s

tests/test_generate_url.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,21 +407,21 @@ def test_generate_url_with_all_params(self):
407407
def test_get_signature_with_100_expire_seconds(self):
408408
url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png"
409409
signature = self.client.url_obj.get_signature(
410-
self,"private_key_test", url, "https://test-domain.com/test-endpoint/", 100
410+
"private_key_test", url, "https://test-domain.com/test-endpoint/", 100
411411
)
412412
self.assertEqual(signature, "5e5037a31a7121cbe2964e220b4338cc6e1ba66d")
413413

414414
def test_get_signature_without_expire_seconds(self):
415415
url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png"
416416
signature = self.client.url_obj.get_signature(
417-
self, "private_key_test", url, "https://test-domain.com/test-endpoint/", 0
417+
"private_key_test", url, "https://test-domain.com/test-endpoint/", 0
418418
)
419419
self.assertEqual(signature, "41b3075c40bc84147eb71b8b49ae7fbf349d0f00")
420420

421421
def test_get_signature_without_expire_seconds_without_slash(self):
422422
url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png"
423423
signature = self.client.url_obj.get_signature(
424-
self,"private_key_test", url, "https://test-domain.com/test-endpoint", 0
424+
"private_key_test", url, "https://test-domain.com/test-endpoint", 0
425425
)
426426
self.assertEqual(signature, "41b3075c40bc84147eb71b8b49ae7fbf349d0f00")
427427

0 commit comments

Comments
 (0)