Index: sdk/lib/_internal/pub/lib/src/utils.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart |
index 7e5d92f03bbd0ef2409cbb8d8937e5ec5fb32a4d..931b1770e67280bfe81f3fb11e55df0909f2256a 100644 |
--- a/sdk/lib/_internal/pub/lib/src/utils.dart |
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart |
@@ -15,6 +15,7 @@ import 'dart:mirrors'; |
import "package:analyzer/analyzer.dart"; |
import "package:crypto/crypto.dart"; |
import 'package:path/path.dart' as path; |
+import "package:stack_trace/stack_trace.dart"; |
import 'dart.dart'; |
@@ -112,6 +113,19 @@ String pluralize(String name, int number, {String plural}) { |
return '${name}s'; |
} |
+/// Creates a URL string for [address]:[port]. |
+/// |
+/// Handles properly formatting IPv6 addresses. |
+String baseUrlForAddress(InternetAddress address, int port) { |
+ // IPv6 addresses in URLs need to be enclosed in square brackets to avoid |
+ // URL ambiguity with the ":" in the address. |
+ if (address.type == InternetAddressType.IP_V6) { |
+ return "http://[${address.address}]:$port"; |
+ } |
+ |
+ return "http://${address.address}:$port"; |
+} |
+ |
/// Flattens nested lists inside an iterable into a single list containing only |
/// non-list elements. |
List flatten(Iterable nested) { |