Skip to content

Commit e2ce24a

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
authored andcommitted
query encoding logic
1 parent ec8f633 commit e2ce24a

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

imagekitio/constants/defaults.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ class Default(enum.Enum):
1717
SIGNATURE_PARAMETER = "ik-s"
1818
TIMESTAMP_PARAMETER = "ik-t"
1919
IGNORE_CHARACTERS = '~@#$&()*!+=:;,?/\''
20-
IGNORE_CHARACTERS_WITHOUT_COMMA = '~@#$&()*!+=:;?/\''

imagekitio/url.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,8 @@ def transformation_to_str(transformation):
216216
def encodeURI(url_str):
217217
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
218218
if "?" in url_str:
219-
# here, we have applied the quote(unquote(url)) function to handle the query string.
220-
# This function ensures that characters in the query are properly encoded. While some characters are already encoded, others require encoding for correct processing.
221-
encoded_url = quote(url_str.split('?')[0], safe=Default.IGNORE_CHARACTERS.value)+"?"+quote(unquote(url_str.split('?')[1]), safe=Default.IGNORE_CHARACTERS_WITHOUT_COMMA.value)
219+
# here we are not encoding query parameters as it is allready encoded
220+
encoded_url = quote(url_str.split('?')[0], safe=Default.IGNORE_CHARACTERS.value)+"?"+url_str.split('?')[1]
222221
else:
223222
encoded_url = quote(url_str, safe=Default.IGNORE_CHARACTERS.value)
224223
return encoded_url

0 commit comments

Comments
 (0)