1818import typing
1919from pathlib import Path
2020from typing import Any , Dict , List , Optional , Union , cast
21+ from urllib .parse import parse_qs
2122
2223import playwright ._impl ._network as network
2324from playwright ._impl ._api_structures import (
5354FormType = Dict [str , Union [bool , float , str ]]
5455DataType = Union [Any , bytes , str ]
5556MultipartType = Dict [str , Union [bytes , bool , float , str , FilePayload ]]
56- ParamsType = Dict [str , Union [bool , float , str ]]
57+ ParamsType = Union [ Dict [str , Union [bool , float , str ]], str ]
5758
5859
5960class APIRequest :
@@ -404,7 +405,7 @@ async def _inner_fetch(
404405 "fetch" ,
405406 {
406407 "url" : url ,
407- "params" : object_to_array (params ),
408+ "params" : params_to_protocol (params ),
408409 "method" : method ,
409410 "headers" : serialized_headers ,
410411 "postData" : post_data ,
@@ -429,6 +430,23 @@ async def storage_state(
429430 return result
430431
431432
433+ def params_to_protocol (params : Optional [ParamsType ]) -> Optional [List [NameValue ]]:
434+ if not params :
435+ return None
436+ if isinstance (params , dict ):
437+ return object_to_array (params )
438+ if params .startswith ("?" ):
439+ params = params [1 :]
440+ parsed = parse_qs (params )
441+ if not parsed :
442+ return None
443+ out = []
444+ for name , values in parsed .items ():
445+ for value in values :
446+ out .append (NameValue (name = name , value = value ))
447+ return out
448+
449+
432450def file_payload_to_json (payload : FilePayload ) -> ServerFilePayload :
433451 return ServerFilePayload (
434452 name = payload ["name" ],
0 commit comments