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

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 65663002: Default to "127.0.0.1" in pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 1 month 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
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698