| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Generic utility functions. Stuff that should possibly be in core. | 5 /// Generic utility functions. Stuff that should possibly be in core. |
| 6 library pub.utils; | 6 library pub.utils; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import "dart:collection"; | 9 import "dart:collection"; |
| 10 import "dart:convert"; | 10 import "dart:convert"; |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 for (var metacharacter in r"\^$.*+?()[]{}|".split("")) { | 226 for (var metacharacter in r"\^$.*+?()[]{}|".split("")) { |
| 227 string = string.replaceAll(metacharacter, "\\$metacharacter"); | 227 string = string.replaceAll(metacharacter, "\\$metacharacter"); |
| 228 } | 228 } |
| 229 | 229 |
| 230 return string; | 230 return string; |
| 231 } | 231 } |
| 232 | 232 |
| 233 /// Creates a URL string for [address]:[port]. | 233 /// Creates a URL string for [address]:[port]. |
| 234 /// | 234 /// |
| 235 /// Handles properly formatting IPv6 addresses. | 235 /// Handles properly formatting IPv6 addresses. |
| 236 String baseUrlForAddress(InternetAddress address, int port) { | 236 Uri baseUrlForAddress(InternetAddress address, int port) { |
| 237 // IPv6 addresses in URLs need to be enclosed in square brackets to avoid | 237 // IPv6 addresses in URLs need to be enclosed in square brackets to avoid |
| 238 // URL ambiguity with the ":" in the address. | 238 // URL ambiguity with the ":" in the address. |
| 239 if (address.type == InternetAddressType.IP_V6) { | 239 if (address.type == InternetAddressType.IP_V6) { |
| 240 return "http://[${address.address}]:$port"; | 240 return new Uri(scheme: "http", host: "[${address.address}]", port: port); |
| 241 } | 241 } |
| 242 | 242 |
| 243 return "http://${address.address}:$port"; | 243 return new Uri(scheme: "http", host: address.address, port: port); |
| 244 } | 244 } |
| 245 | 245 |
| 246 /// Flattens nested lists inside an iterable into a single list containing only | 246 /// Flattens nested lists inside an iterable into a single list containing only |
| 247 /// non-list elements. | 247 /// non-list elements. |
| 248 List flatten(Iterable nested) { | 248 List flatten(Iterable nested) { |
| 249 var result = []; | 249 var result = []; |
| 250 helper(list) { | 250 helper(list) { |
| 251 for (var element in list) { | 251 for (var element in list) { |
| 252 if (element is List) { | 252 if (element is List) { |
| 253 helper(element); | 253 helper(element); |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 error is AnalyzerErrorGroup || | 919 error is AnalyzerErrorGroup || |
| 920 error is IsolateSpawnException || | 920 error is IsolateSpawnException || |
| 921 error is FileSystemException || | 921 error is FileSystemException || |
| 922 error is HttpException || | 922 error is HttpException || |
| 923 error is HttpException || | 923 error is HttpException || |
| 924 error is OSError || | 924 error is OSError || |
| 925 error is ProcessException || | 925 error is ProcessException || |
| 926 error is SocketException || | 926 error is SocketException || |
| 927 error is WebSocketException; | 927 error is WebSocketException; |
| 928 } | 928 } |
| OLD | NEW |