Chromium Code Reviews| 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('uri'); | 5 #library('uri'); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A parsed URI, inspired by: | 8 * A parsed URI, inspired by Closure's [URI][] class. Implements [RFC-3986][]. |
| 9 * http://closure-library.googlecode.com/svn/docs/class_goog_Uri.html | 9 * [uri]: http://closure-library.googlecode.com/svn/docs/class_goog_Uri.html |
|
ahe
2012/04/12 18:24:22
I don't think this follows the conventions we foll
Bob Nystrom
2012/04/16 22:04:23
I didn't even remember that the old guide specifie
| |
| 10 * [RFC-3986]: http://tools.ietf.org/html/rfc3986#section-4.3) | |
| 10 */ | 11 */ |
| 11 class Uri { | 12 class Uri { |
| 12 final String scheme; | 13 final String scheme; |
| 13 final String userInfo; | 14 final String userInfo; |
| 14 final String domain; | 15 final String domain; |
| 15 final int port; | 16 final int port; |
| 16 final String path; | 17 final String path; |
| 17 final String query; | 18 final String query; |
| 18 final String fragment; | 19 final String fragment; |
| 19 | 20 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 | 66 |
| 66 static final _COMPONENT_SCHEME = 1; | 67 static final _COMPONENT_SCHEME = 1; |
| 67 static final _COMPONENT_USER_INFO = 2; | 68 static final _COMPONENT_USER_INFO = 2; |
| 68 static final _COMPONENT_DOMAIN = 3; | 69 static final _COMPONENT_DOMAIN = 3; |
| 69 static final _COMPONENT_PORT = 4; | 70 static final _COMPONENT_PORT = 4; |
| 70 static final _COMPONENT_PATH = 5; | 71 static final _COMPONENT_PATH = 5; |
| 71 static final _COMPONENT_QUERY_DATA = 6; | 72 static final _COMPONENT_QUERY_DATA = 6; |
| 72 static final _COMPONENT_FRAGMENT = 7; | 73 static final _COMPONENT_FRAGMENT = 7; |
| 73 | 74 |
| 74 /** | 75 /** |
| 75 * Determines whether a URI is absolute. | 76 * Returns `true` if the URI is absolute. |
|
ahe
2012/04/12 18:24:22
[true] instead of `true`.
Bob Nystrom
2012/04/16 22:04:23
[true] is for links to identifiers, but "true" is
| |
| 76 * | |
| 77 * See: http://tools.ietf.org/html/rfc3986#section-4.3 | |
| 78 */ | 77 */ |
| 79 bool isAbsolute() { | 78 bool isAbsolute() { |
| 80 if ("" == scheme) return false; | 79 if ("" == scheme) return false; |
| 81 if ("" != fragment) return false; | 80 if ("" != fragment) return false; |
| 82 return true; | 81 return true; |
| 83 | 82 |
| 84 /* absolute-URI = scheme ":" hier-part [ "?" query ] | 83 /* absolute-URI = scheme ":" hier-part [ "?" query ] |
| 85 * hier-part = "//" authority path-abempty | 84 * hier-part = "//" authority path-abempty |
| 86 * / path-absolute | 85 * / path-absolute |
| 87 * / path-rootless | 86 * / path-rootless |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 appendSlash = true; | 205 appendSlash = true; |
| 207 } else if ("." == segment) { | 206 } else if ("." == segment) { |
| 208 appendSlash = true; | 207 appendSlash = true; |
| 209 } else { | 208 } else { |
| 210 output.add(segment); | 209 output.add(segment); |
| 211 } | 210 } |
| 212 } | 211 } |
| 213 if (appendSlash) output.add(""); | 212 if (appendSlash) output.add(""); |
| 214 return Strings.join(output, "/"); | 213 return Strings.join(output, "/"); |
| 215 } | 214 } |
| OLD | NEW |