| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 static int _parseIntOrZero(String val) { | 47 static int _parseIntOrZero(String val) { |
| 48 if (val !== null && val != '') { | 48 if (val !== null && val != '') { |
| 49 return parseInt(val); | 49 return parseInt(val); |
| 50 } else { | 50 } else { |
| 51 return 0; | 51 return 0; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 // 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 |
| 56 static final RegExp _splitRe = const RegExp( | 56 static const RegExp _splitRe = const RegExp( |
| 57 '^' | 57 '^' |
| 58 '(?:' | 58 '(?:' |
| 59 '([^:/?#.]+)' // scheme - ignore special characters | 59 '([^:/?#.]+)' // scheme - ignore special characters |
| 60 // used by other URL parts such as :, | 60 // used by other URL parts such as :, |
| 61 // ?, /, #, and . | 61 // ?, /, #, and . |
| 62 ':)?' | 62 ':)?' |
| 63 '(?://' | 63 '(?://' |
| 64 '(?:([^/?#]*)@)?' // userInfo | 64 '(?:([^/?#]*)@)?' // userInfo |
| 65 '([\\w\\d\\-\\u0100-\\uffff.%]*)' | 65 '([\\w\\d\\-\\u0100-\\uffff.%]*)' |
| 66 // domain - restrict to letters, | 66 // domain - restrict to letters, |
| 67 // digits, dashes, dots, percent | 67 // digits, dashes, dots, percent |
| 68 // escapes, and unicode characters. | 68 // escapes, and unicode characters. |
| 69 '(?::([0-9]+))?' // port | 69 '(?::([0-9]+))?' // port |
| 70 ')?' | 70 ')?' |
| 71 '([^?#]+)?' // path | 71 '([^?#]+)?' // path |
| 72 '(?:\\?([^#]*))?' // query | 72 '(?:\\?([^#]*))?' // query |
| 73 '(?:#(.*))?' // fragment | 73 '(?:#(.*))?' // fragment |
| 74 '\$'); | 74 '\$'); |
| 75 | 75 |
| 76 static final _COMPONENT_SCHEME = 1; | 76 static const _COMPONENT_SCHEME = 1; |
| 77 static final _COMPONENT_USER_INFO = 2; | 77 static const _COMPONENT_USER_INFO = 2; |
| 78 static final _COMPONENT_DOMAIN = 3; | 78 static const _COMPONENT_DOMAIN = 3; |
| 79 static final _COMPONENT_PORT = 4; | 79 static const _COMPONENT_PORT = 4; |
| 80 static final _COMPONENT_PATH = 5; | 80 static const _COMPONENT_PATH = 5; |
| 81 static final _COMPONENT_QUERY_DATA = 6; | 81 static const _COMPONENT_QUERY_DATA = 6; |
| 82 static final _COMPONENT_FRAGMENT = 7; | 82 static const _COMPONENT_FRAGMENT = 7; |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Returns `true` if the URI is absolute. | 85 * Returns `true` if the URI is absolute. |
| 86 */ | 86 */ |
| 87 bool isAbsolute() { | 87 bool isAbsolute() { |
| 88 if ("" == scheme) return false; | 88 if ("" == scheme) return false; |
| 89 if ("" != fragment) return false; | 89 if ("" != fragment) return false; |
| 90 return true; | 90 return true; |
| 91 | 91 |
| 92 /* absolute-URI = scheme ":" hier-part [ "?" query ] | 92 /* absolute-URI = scheme ":" hier-part [ "?" query ] |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 223 } |
| 224 | 224 |
| 225 static void _addIfNonEmpty(StringBuffer sb, String test, | 225 static void _addIfNonEmpty(StringBuffer sb, String test, |
| 226 String first, String second) { | 226 String first, String second) { |
| 227 if ("" != test) { | 227 if ("" != test) { |
| 228 sb.add(first === null ? "null" : first); | 228 sb.add(first === null ? "null" : first); |
| 229 sb.add(second === null ? "null" : second); | 229 sb.add(second === null ? "null" : second); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 } | 232 } |
| OLD | NEW |