@@ -88,6 +88,58 @@ def test_uri_parse_http_with_query_string():
8888 testing.assert_equal(uri._original_path, " /job" )
8989 testing.assert_equal(uri.request_uri, " /job?title=engineer" )
9090 testing.assert_equal(uri.query_string, " title=engineer" )
91+ testing.assert_equal(uri.queries[" title" ], " engineer" )
92+
93+ def test_uri_parse_multiple_query_parameters ():
94+ var uri = URI .parse(" http://example.com/search?q=python&page=1&limit=20" )
95+ testing.assert_equal(uri.scheme, " http" )
96+ testing.assert_equal(uri.host, " example.com" )
97+ testing.assert_equal(uri.path, " /search" )
98+ testing.assert_equal(uri.query_string, " q=python&page=1&limit=20" )
99+ testing.assert_equal(uri.queries[" q" ], " python" )
100+ testing.assert_equal(uri.queries[" page" ], " 1" )
101+ testing.assert_equal(uri.queries[" limit" ], " 20" )
102+ testing.assert_equal(uri.request_uri, " /search?q=python&page=1&limit=20" )
103+
104+ def test_uri_parse_query_with_special_characters ():
105+ var uri = URI .parse(" https://example.com/path?name=John+Doe&email=john%40e xample.com" )
106+ testing.assert_equal(uri.scheme, " https" )
107+ testing.assert_equal(uri.host, " example.com" )
108+ testing.assert_equal(uri.path, " /path" )
109+ testing.assert_equal(uri.query_string, " name=John+Doe&email=john%40e xample.com" )
110+ # testing.assert_equal(uri.queries["name"], "John Doe") - fails, contains John+Doe
111+ # testing.assert_equal(uri.queries["email"], "john@example.com") - fails, contains john%40example.com
112+
113+ def test_uri_parse_empty_query_values ():
114+ var uri = URI .parse(" http://example.com/api?key=&token=&empty" )
115+ testing.assert_equal(uri.query_string, " key=&token=&empty" )
116+ testing.assert_equal(uri.queries[" key" ], " " )
117+ testing.assert_equal(uri.queries[" token" ], " " )
118+ testing.assert_equal(uri.queries[" empty" ], " " )
119+
120+ def test_uri_parse_complex_query ():
121+ var uri = URI .parse(" https://example.com/search?q=test&filter[category]=books&filter[price]=10-20&sort=desc&page=1" )
122+ testing.assert_equal(uri.scheme, " https" )
123+ testing.assert_equal(uri.host, " example.com" )
124+ testing.assert_equal(uri.path, " /search" )
125+ testing.assert_equal(uri.query_string, " q=test&filter[category]=books&filter[price]=10-20&sort=desc&page=1" )
126+ testing.assert_equal(uri.queries[" q" ], " test" )
127+ testing.assert_equal(uri.queries[" filter[category]" ], " books" )
128+ testing.assert_equal(uri.queries[" filter[price]" ], " 10-20" )
129+ testing.assert_equal(uri.queries[" sort" ], " desc" )
130+ testing.assert_equal(uri.queries[" page" ], " 1" )
131+
132+ def test_uri_parse_query_with_unicode ():
133+ var uri = URI .parse(" http://example.com/search?q=%E 2%82% AC&lang=%F 0%9F%87% A9%F 0%9F%87% AA" )
134+ testing.assert_equal(uri.query_string, " q=%E 2%82% AC&lang=%F 0%9F%87% A9%F 0%9F%87% AA" )
135+ # testing.assert_equal(uri.queries["q"], "€") - fails, contains %E2%82%AC
136+ # testing.assert_equal(uri.queries["lang"], "🇩🇪") - fails, contains %F0%9F%87%A9%F0%9F%87%AA
137+
138+ # def test_uri_parse_query_with_fragments():
139+ # var uri = URI.parse("http://example.com/page?id=123#section1")
140+ # testing.assert_equal(uri.query_string, "id=123")
141+ # testing.assert_equal(uri.queries["id"], "123")
142+ # testing.assert_equal(...) - how do we treat fragments?
91143
92144
93145def test_uri_parse_http_with_hash ():
0 commit comments