Skip to content

Commit

Permalink
Support multiple values for a key param
Browse files Browse the repository at this point in the history
  • Loading branch information
lionick committed Jul 8, 2024
1 parent 56a4799 commit bd080a0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/idpyoidc/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ def set_defaults(self):
for key, val in self.c_default.items():
self._dict.setdefault(key, val)

def to_urlencoded(self):
def to_urlencoded(self, doseq=False):
"""
Creates a string using the application/x-www-form-urlencoded format
:doseq: If set to true, key=value pairs separated by '&' are generated for each element of the value sequence for the key.
:return: A string of the application/x-www-form-urlencoded format
"""

Expand Down Expand Up @@ -135,15 +136,15 @@ def to_urlencoded(self):
params.append((key, str(val)))

try:
return urlencode(params)
return urlencode(params, doseq)
except UnicodeEncodeError:
_val = []
for k, v in params:
try:
_val.append((k, v.encode("utf-8")))
except TypeError:
_val.append((k, v))
return urlencode(_val)
return urlencode(_val, doseq)

def serialize(self, method="urlencoded", **kwargs):
"""
Expand Down

0 comments on commit bd080a0

Please sign in to comment.