diff --git a/jc/parsers/url.py b/jc/parsers/url.py index 31bb9640..95c70db0 100644 --- a/jc/parsers/url.py +++ b/jc/parsers/url.py @@ -29,11 +29,14 @@ Schema: ], "query": { object or null : [ array or null - string + string # [0] ] }, "query_list": [ array or null - string + [ + string, # [1] + string + ] ], "fragment": string or null, "username": string or null, @@ -42,17 +45,48 @@ Schema: "port": integer or null } + [0] Duplicate query-keys will have their values consolidated into the + array of query-values + [1] The first array value is the query-key and the second value is the + query-value + Examples: - $ echo "http://example.com/test/path?q1=foo&q2=bar#frag" | jc --url -p + % echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\ + | jc --url -p { + "quoted": "http://example.com/test/path?q1%3Dfoo%26q1%3Dbar%26q2%3Dbaz#frag", + "unquoted": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag", "scheme": "http", "netloc": "example.com", "path": "/test/path", + "path_list": [ + "test", + "path" + ], "query": { - "q1": "foo", - "q2": "bar" + "q1": [ + "foo", + "bar" + ], + "q2": [ + "baz" + ] }, + "query_list": [ + [ + "q1", + "foo" + ], + [ + "q1", + "bar" + ], + [ + "q2", + "baz" + ] + ], "fragment": "frag", "username": null, "password": null, @@ -62,11 +96,16 @@ Examples: $ echo "ftp://localhost/filepath" | jc --url -p { + "quoted": "ftp://localhost/filepath", + "unquoted": "ftp://localhost/filepath", "scheme": "ftp", "netloc": "localhost", "path": "/filepath", - "path_list": ['filepath'], + "path_list": [ + "filepath" + ], "query": null, + "query_list": null, "fragment": null, "username": null, "password": null,