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:utf'); | 8 #import('dart:utf'); |
8 | 9 |
9 #source('encode_decode.dart'); | 10 #source('encode_decode.dart'); |
10 #source('helpers.dart'); | 11 #source('helpers.dart'); |
11 | 12 |
12 /** | 13 /** |
13 * A parsed URI, inspired by Closure's [URI][] class. Implements [RFC-3986][]. | 14 * A parsed URI, inspired by Closure's [URI][] class. Implements [RFC-3986][]. |
14 * [uri]: http://closure-library.googlecode.com/svn/docs/class_goog_Uri.html | 15 * [uri]: http://closure-library.googlecode.com/svn/docs/class_goog_Uri.html |
15 * [RFC-3986]: http://tools.ietf.org/html/rfc3986#section-4.3) | 16 * [RFC-3986]: http://tools.ietf.org/html/rfc3986#section-4.3) |
16 */ | 17 */ |
(...skipping 21 matching lines...) Expand all Loading... |
38 String this.domain = "", int this.port = 0, | 39 String this.domain = "", int this.port = 0, |
39 String this.path = "", String this.query = "", | 40 String this.path = "", String this.query = "", |
40 String this.fragment = ""]); | 41 String this.fragment = ""]); |
41 | 42 |
42 Uri(String uri) : this.fromString(uri); | 43 Uri(String uri) : this.fromString(uri); |
43 | 44 |
44 static String _emptyIfNull(String val) => val != null ? val : ''; | 45 static String _emptyIfNull(String val) => val != null ? val : ''; |
45 | 46 |
46 static int _parseIntOrZero(String val) { | 47 static int _parseIntOrZero(String val) { |
47 if (val !== null && val != '') { | 48 if (val !== null && val != '') { |
48 return Math.parseInt(val); | 49 return parseInt(val); |
49 } else { | 50 } else { |
50 return 0; | 51 return 0; |
51 } | 52 } |
52 } | 53 } |
53 | 54 |
54 // NOTE: This code was ported from: closure-library/closure/goog/uri/utils.js | 55 // NOTE: This code was ported from: closure-library/closure/goog/uri/utils.js |
55 static final RegExp _splitRe = const RegExp( | 56 static final RegExp _splitRe = const RegExp( |
56 '^' | 57 '^' |
57 '(?:' | 58 '(?:' |
58 '([^:/?#.]+)' // scheme - ignore special characters | 59 '([^:/?#.]+)' // scheme - ignore special characters |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 223 } |
223 | 224 |
224 static void _addIfNonEmpty(StringBuffer sb, String test, | 225 static void _addIfNonEmpty(StringBuffer sb, String test, |
225 String first, String second) { | 226 String first, String second) { |
226 if ("" != test) { | 227 if ("" != test) { |
227 sb.add(first === null ? "null" : first); | 228 sb.add(first === null ? "null" : first); |
228 sb.add(second === null ? "null" : second); | 229 sb.add(second === null ? "null" : second); |
229 } | 230 } |
230 } | 231 } |
231 } | 232 } |
OLD | NEW |