Skip to content

Commit 81d24f8

Browse files
committed
Use rstrip to remove trailing =s
1 parent f53dfa3 commit 81d24f8

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

uid2_client/uid2_base64_url_coder.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ def encode(input):
1111
encoded_token = base64.urlsafe_b64encode(input).decode('ascii')
1212
# urlsafe_b64encode doesn't remove the '=' padding per the spec so we should remove it
1313
# as '=' is a reserved char in URL spec
14-
count = 0
15-
for i in range(3):
16-
if encoded_token[len(encoded_token) - 1 - i] == '=':
17-
count = count + 1
18-
# encoded_token[:-0] will empty the whole string!
19-
if count > 0:
20-
return encoded_token[:-count]
21-
return encoded_token
14+
return encoded_token.rstrip('=')
2215

2316
@staticmethod
2417
def decode(token):

0 commit comments

Comments
 (0)