Version 2.12.0-213.0.dev
Merge commit 'eaf5be7b80e966c13d9715b655f85e997301fc72' into 'dev'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a97fcd..ffeea12 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -237,6 +237,11 @@
* Class `BytesBuilder` is moved from `dart:io` to `dart:typed_data`.
It's temporarily being exported from `dart:io` as well.
+### `dart:uri`
+
+* [#42564]: Solved inconsistency in `Uri.https` and `Uri.http` constructors'
+ `queryParams` type.
+
### Dart VM
* **Breaking Change** [#42982][]: `dart_api_dl.cc` is renamed to
diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart
index 143ad63..daf7f67 100644
--- a/sdk/lib/core/uri.dart
+++ b/sdk/lib/core/uri.dart
@@ -163,7 +163,7 @@
* argument.
*/
factory Uri.http(String authority, String unencodedPath,
- [Map<String, String>? queryParameters]) = _Uri.http;
+ [Map<String, dynamic>? queryParameters]) = _Uri.http;
/**
* Creates a new `https` URI from authority, path and query.
@@ -172,7 +172,7 @@
* which is set to `https`.
*/
factory Uri.https(String authority, String unencodedPath,
- [Map<String, String>? queryParameters]) = _Uri.https;
+ [Map<String, dynamic>? queryParameters]) = _Uri.https;
/**
* Creates a new file URI from an absolute or relative file path.
@@ -1543,13 +1543,13 @@
/// Implementation of [Uri.http].
factory _Uri.http(String authority, String unencodedPath,
- [Map<String, String>? queryParameters]) {
+ [Map<String, dynamic>? queryParameters]) {
return _makeHttpUri("http", authority, unencodedPath, queryParameters);
}
/// Implementation of [Uri.https].
factory _Uri.https(String authority, String unencodedPath,
- [Map<String, String>? queryParameters]) {
+ [Map<String, dynamic>? queryParameters]) {
return _makeHttpUri("https", authority, unencodedPath, queryParameters);
}
@@ -1630,7 +1630,7 @@
}
static _Uri _makeHttpUri(String scheme, String? authority,
- String unencodedPath, Map<String, String>? queryParameters) {
+ String unencodedPath, Map<String, dynamic>? queryParameters) {
var userInfo = "";
String? host;
int? port;
diff --git a/tests/corelib/uri_http_test.dart b/tests/corelib/uri_http_test.dart
index 399c403..bfc57bf 100644
--- a/tests/corelib/uri_http_test.dart
+++ b/tests/corelib/uri_http_test.dart
@@ -4,7 +4,7 @@
import "package:expect/expect.dart";
-testHttpUri() {
+void testHttpUri() {
void check(Uri uri, String expected) {
Expect.equals(expected, uri.toString());
}
@@ -40,7 +40,7 @@
check(new Uri.http('[ff02::1%%321]', ''), 'http://[ff02::1%2521]');
}
-testHttpsUri() {
+void testHttpsUri() {
void check(Uri uri, String expected) {
Expect.equals(expected, uri.toString());
}
@@ -71,7 +71,7 @@
check(new Uri.https("[::127.0.0.1]", "a"), "https://[::127.0.0.1]/a");
}
-testResolveHttpScheme() {
+void testResolveHttpScheme() {
String s = "//myserver:1234/path/some/thing";
Uri uri = Uri.parse(s);
Uri http = new Uri(scheme: "http");
@@ -80,8 +80,34 @@
Expect.equals("https:$s", https.resolveUri(uri).toString());
}
+void testQuery() {
+ var uri = Uri.http("example.com", "a/b", <String, dynamic>{
+ "a": "b",
+ "c": ["d", "e"]
+ });
+ Expect.equals(uri.toString(), "http://example.com/a/b?a=b&c=d&c=e");
+ Expect.listEquals(uri.queryParametersAll["c"]!, ["d", "e"]);
+
+ uri = Uri.https("example.com", "a/b", <String, dynamic>{
+ "a": "b",
+ "c": ["d", "e"]
+ });
+ Expect.equals(uri.toString(), "https://example.com/a/b?a=b&c=d&c=e");
+ Expect.listEquals(uri.queryParametersAll["c"]!, ["d", "e"]);
+
+ uri = Uri.http("example.com", "a/b", {
+ "a b c": ["d e", "f g"]
+ });
+ Expect.equals(uri.toString(), "http://example.com/a/b?a+b+c=d+e&a+b+c=f+g");
+ uri = Uri.https("example.com", "a/b", {
+ "a b c": ["d e", "f g"]
+ });
+ Expect.equals(uri.toString(), "https://example.com/a/b?a+b+c=d+e&a+b+c=f+g");
+}
+
main() {
testHttpUri();
testHttpsUri();
testResolveHttpScheme();
+ testQuery();
}
diff --git a/tests/corelib_2/uri_http_test.dart b/tests/corelib_2/uri_http_test.dart
index 399c403..4fd639d 100644
--- a/tests/corelib_2/uri_http_test.dart
+++ b/tests/corelib_2/uri_http_test.dart
@@ -4,7 +4,7 @@
import "package:expect/expect.dart";
-testHttpUri() {
+void testHttpUri() {
void check(Uri uri, String expected) {
Expect.equals(expected, uri.toString());
}
@@ -40,7 +40,7 @@
check(new Uri.http('[ff02::1%%321]', ''), 'http://[ff02::1%2521]');
}
-testHttpsUri() {
+void testHttpsUri() {
void check(Uri uri, String expected) {
Expect.equals(expected, uri.toString());
}
@@ -71,7 +71,7 @@
check(new Uri.https("[::127.0.0.1]", "a"), "https://[::127.0.0.1]/a");
}
-testResolveHttpScheme() {
+void testResolveHttpScheme() {
String s = "//myserver:1234/path/some/thing";
Uri uri = Uri.parse(s);
Uri http = new Uri(scheme: "http");
@@ -80,8 +80,34 @@
Expect.equals("https:$s", https.resolveUri(uri).toString());
}
+void testQuery() {
+ var uri = Uri.http("example.com", "a/b", <String, dynamic>{
+ "a": "b",
+ "c": ["d", "e"]
+ });
+ Expect.equals(uri.toString(), "http://example.com/a/b?a=b&c=d&c=e");
+ Expect.listEquals(uri.queryParametersAll["c"], ["d", "e"]);
+
+ uri = Uri.https("example.com", "a/b", <String, dynamic>{
+ "a": "b",
+ "c": ["d", "e"]
+ });
+ Expect.equals(uri.toString(), "https://example.com/a/b?a=b&c=d&c=e");
+ Expect.listEquals(uri.queryParametersAll["c"], ["d", "e"]);
+
+ uri = Uri.http("example.com", "a/b", {
+ "a b c": ["d e", "f g"]
+ });
+ Expect.equals(uri.toString(), "http://example.com/a/b?a+b+c=d+e&a+b+c=f+g");
+ uri = Uri.https("example.com", "a/b", {
+ "a b c": ["d e", "f g"]
+ });
+ Expect.equals(uri.toString(), "https://example.com/a/b?a+b+c=d+e&a+b+c=f+g");
+}
+
main() {
testHttpUri();
testHttpsUri();
testResolveHttpScheme();
+ testQuery();
}
diff --git a/tools/VERSION b/tools/VERSION
index 4ba8897..1562440 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 12
PATCH 0
-PRERELEASE 212
+PRERELEASE 213
PRERELEASE_PATCH 0
\ No newline at end of file