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 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * A parsed URI, such as a URL. | 8 * A parsed URI, such as a URL. |
9 * | 9 * |
10 * **See also:** | 10 * **See also:** |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 * | 1002 * |
1003 * If this `Uri` does not have a fragment, it is itself returned. | 1003 * If this `Uri` does not have a fragment, it is itself returned. |
1004 */ | 1004 */ |
1005 Uri removeFragment() { | 1005 Uri removeFragment() { |
1006 if (!this.hasFragment) return this; | 1006 if (!this.hasFragment) return this; |
1007 return new Uri._internal(scheme, _userInfo, _host, _port, | 1007 return new Uri._internal(scheme, _userInfo, _host, _port, |
1008 _path, _query, null); | 1008 _path, _query, null); |
1009 } | 1009 } |
1010 | 1010 |
1011 /** | 1011 /** |
1012 * Returns the URI path split into its segments. Each of the | 1012 * Returns the URI path split into its segments. Each of the segments in the |
1013 * segments in the returned list have been decoded. If the path is | 1013 * returned list have been decoded. If the path is empty the empty list will |
1014 * empty the empty list will be returned. A leading slash `/` does | 1014 * be returned. A leading slash `/` does not affect the segments returned. |
1015 * not affect the segments returned. | |
1016 * | 1015 * |
1017 * The returned list is unmodifiable and will throw [UnsupportedError] on any | 1016 * The returned list is unmodifiable and will throw [UnsupportedError] on any |
1018 * calls that would mutate it. | 1017 * calls that would mutate it. |
1019 */ | 1018 */ |
1020 List<String> get pathSegments { | 1019 List<String> get pathSegments { |
1021 if (_pathSegments == null) { | 1020 var result = _pathSegments; |
1022 var pathToSplit = !path.isEmpty && path.codeUnitAt(0) == _SLASH | 1021 if (result != null) return result; |
1023 ? path.substring(1) | 1022 |
1024 : path; | 1023 var pathToSplit = path; |
1025 _pathSegments = new UnmodifiableListView( | 1024 if (pathToSplit.isNotEmpty && pathToSplit.codeUnitAt(0) == _SLASH) { |
1026 pathToSplit == "" ? const<String>[] | 1025 pathToSplit = pathToSplit.substring(1); |
1027 : pathToSplit.split("/") | |
1028 .map(Uri.decodeComponent) | |
1029 .toList(growable: false)); | |
1030 } | 1026 } |
1031 return _pathSegments; | 1027 result = (pathToSplit == "") |
| 1028 ? const<String>[] |
| 1029 : new List<String>.unmodifiable( |
| 1030 pathToSplit.split("/").map(Uri.decodeComponent)); |
| 1031 _pathSegments = result; |
| 1032 return result; |
1032 } | 1033 } |
1033 | 1034 |
1034 /** | 1035 /** |
1035 * Returns the URI query split into a map according to the rules | 1036 * Returns the URI query split into a map according to the rules |
1036 * specified for FORM post in the [HTML 4.01 specification section 17.13.4] | 1037 * specified for FORM post in the [HTML 4.01 specification section 17.13.4] |
1037 * (http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4 | 1038 * (http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4 |
1038 * "HTML 4.01 section 17.13.4"). Each key and value in the returned map | 1039 * "HTML 4.01 section 17.13.4"). Each key and value in the returned map |
1039 * has been decoded. If there is no query the empty map is returned. | 1040 * has been decoded. If there is no query the empty map is returned. |
1040 * | 1041 * |
1041 * Keys in the query string that have no value are mapped to the | 1042 * Keys in the query string that have no value are mapped to the |
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2611 0xafff, // 0x30 - 0x3f 1111111111110101 | 2612 0xafff, // 0x30 - 0x3f 1111111111110101 |
2612 // @ABCDEFGHIJKLMNO | 2613 // @ABCDEFGHIJKLMNO |
2613 0xffff, // 0x40 - 0x4f 1111111111111111 | 2614 0xffff, // 0x40 - 0x4f 1111111111111111 |
2614 // PQRSTUVWXYZ _ | 2615 // PQRSTUVWXYZ _ |
2615 0x87ff, // 0x50 - 0x5f 1111111111100001 | 2616 0x87ff, // 0x50 - 0x5f 1111111111100001 |
2616 // abcdefghijklmno | 2617 // abcdefghijklmno |
2617 0xfffe, // 0x60 - 0x6f 0111111111111111 | 2618 0xfffe, // 0x60 - 0x6f 0111111111111111 |
2618 // pqrstuvwxyz ~ | 2619 // pqrstuvwxyz ~ |
2619 0x47ff]; // 0x70 - 0x7f 1111111111100010 | 2620 0x47ff]; // 0x70 - 0x7f 1111111111100010 |
2620 } | 2621 } |
OLD | NEW |