Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: lib/src/util/io.dart

Issue 958423002: Add a class to start and stop a Chrome process. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/util/io.dart
diff --git a/lib/src/util/io.dart b/lib/src/util/io.dart
index 8a4a9036c766984ad7e2b1293decc6960ba3f7bd..1cf51104d023d95657ce5f8037087f3cb2dde4b3 100644
--- a/lib/src/util/io.dart
+++ b/lib/src/util/io.dart
@@ -53,3 +53,20 @@ Future withTempDir(Future fn(String path)) {
.whenComplete(() => tempDir.deleteSync(recursive: true));
});
}
+
+/// Creates a URL string for [address]:[port].
+///
+/// Handles properly formatting IPv6 addresses.
+Uri baseUrlForAddress(InternetAddress address, int port) {
+ if (address.isLoopback) {
+ return new Uri(scheme: "http", host: "localhost", port: 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 new Uri(scheme: "http", host: "[${address.address}]", port: port);
+ }
+
+ return new Uri(scheme: "http", host: address.address, port: port);
+}
« no previous file with comments | « lib/src/runner/browser/chrome.dart ('k') | pubspec.yaml » ('j') | test/browser/chrome_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698