| 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 #library('dart:uri'); | 5 #library('dart:uri'); |
| 6 | 6 |
| 7 #import('dart:math'); | 7 #import('dart:math'); |
| 8 #import('dart:utf'); | 8 #import('dart:utf'); |
| 9 | 9 |
| 10 #source('encode_decode.dart'); | 10 #source('encode_decode.dart'); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 this.port: 0, | 41 this.port: 0, |
| 42 this.path: "", | 42 this.path: "", |
| 43 this.query: "", | 43 this.query: "", |
| 44 this.fragment: ""}); | 44 this.fragment: ""}); |
| 45 | 45 |
| 46 Uri(String uri) : this.fromString(uri); | 46 Uri(String uri) : this.fromString(uri); |
| 47 | 47 |
| 48 static String _emptyIfNull(String val) => val != null ? val : ''; | 48 static String _emptyIfNull(String val) => val != null ? val : ''; |
| 49 | 49 |
| 50 static int _parseIntOrZero(String val) { | 50 static int _parseIntOrZero(String val) { |
| 51 if (val !== null && val != '') { | 51 if (val != null && val != '') { |
| 52 return int.parse(val); | 52 return int.parse(val); |
| 53 } else { | 53 } else { |
| 54 return 0; | 54 return 0; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 // NOTE: This code was ported from: closure-library/closure/goog/uri/utils.js | 58 // NOTE: This code was ported from: closure-library/closure/goog/uri/utils.js |
| 59 static const RegExp _splitRe = const RegExp( | 59 static const RegExp _splitRe = const RegExp( |
| 60 '^' | 60 '^' |
| 61 '(?:' | 61 '(?:' |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 return sb.toString(); | 211 return sb.toString(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 String toString() { | 214 String toString() { |
| 215 StringBuffer sb = new StringBuffer(); | 215 StringBuffer sb = new StringBuffer(); |
| 216 _addIfNonEmpty(sb, scheme, scheme, ':'); | 216 _addIfNonEmpty(sb, scheme, scheme, ':'); |
| 217 if (hasAuthority() || (scheme == "file")) { | 217 if (hasAuthority() || (scheme == "file")) { |
| 218 sb.add("//"); | 218 sb.add("//"); |
| 219 _addIfNonEmpty(sb, userInfo, userInfo, "@"); | 219 _addIfNonEmpty(sb, userInfo, userInfo, "@"); |
| 220 sb.add(domain === null ? "null" : domain); | 220 sb.add(domain == null ? "null" : domain); |
| 221 if (port != 0) { | 221 if (port != 0) { |
| 222 sb.add(":"); | 222 sb.add(":"); |
| 223 sb.add(port.toString()); | 223 sb.add(port.toString()); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 sb.add(path === null ? "null" : path); | 226 sb.add(path == null ? "null" : path); |
| 227 _addIfNonEmpty(sb, query, "?", query); | 227 _addIfNonEmpty(sb, query, "?", query); |
| 228 _addIfNonEmpty(sb, fragment, "#", fragment); | 228 _addIfNonEmpty(sb, fragment, "#", fragment); |
| 229 return sb.toString(); | 229 return sb.toString(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 static void _addIfNonEmpty(StringBuffer sb, String test, | 232 static void _addIfNonEmpty(StringBuffer sb, String test, |
| 233 String first, String second) { | 233 String first, String second) { |
| 234 if ("" != test) { | 234 if ("" != test) { |
| 235 sb.add(first === null ? "null" : first); | 235 sb.add(first == null ? "null" : first); |
| 236 sb.add(second === null ? "null" : second); | 236 sb.add(second == null ? "null" : second); |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 } | 239 } |
| OLD | NEW |