| 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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 } | 812 } |
| 813 } else { | 813 } else { |
| 814 // Relative URI. | 814 // Relative URI. |
| 815 var pathSegments = path.split(sep); | 815 var pathSegments = path.split(sep); |
| 816 _checkWindowsPathReservedCharacters(pathSegments, true); | 816 _checkWindowsPathReservedCharacters(pathSegments, true); |
| 817 return new Uri(pathSegments: pathSegments); | 817 return new Uri(pathSegments: pathSegments); |
| 818 } | 818 } |
| 819 } | 819 } |
| 820 | 820 |
| 821 /** | 821 /** |
| 822 * Returns a new `Uri` based on this one, but with some parts replaced. | |
| 823 * | |
| 824 * This method takes the same parameters as the [new Uri] constructor, | |
| 825 * and they have the same meaning. | |
| 826 * | |
| 827 * At most one of [path] and [pathSegments] must be provided. | |
| 828 * Likewise, at most one of [query] and [queryParameters] must be provided. | |
| 829 * | |
| 830 * Each part that is not provided will default to the corresponding | |
| 831 * value from this `Uri` instead. | |
| 832 * | |
| 833 * This method is different from [Uri.resolve] which overrides in a | |
| 834 * hierarchial manner, | |
| 835 * and can instead replace each part of a `Uri` individually. | |
| 836 * | |
| 837 * Example: | |
| 838 * | |
| 839 * Uri uri1 = Uri.parse("a://b@c:4/d/e?f#g"); | |
| 840 * Uri uri2 = uri1.replace(scheme: "A", path: "D/E/E", fragment: "G"); | |
| 841 * print(uri2); // prints "A://b@c:4/D/E/E/?f#G" | |
| 842 * | |
| 843 * This method acts similarly to using the `new Uri` constructor with | |
| 844 * some of the arguments taken from this `Uri` . Example: | |
| 845 * | |
| 846 * Uri uri3 = new Uri( | |
| 847 * scheme: "A", | |
| 848 * userInfo: uri1.userInfo, | |
| 849 * host: uri1.host, | |
| 850 * port: uri1.port, | |
| 851 * path: "D/E/E", | |
| 852 * query: uri1.query, | |
| 853 * fragment: "G"); | |
| 854 * print(uri3); // prints "A://b@c:4/D/E/E/?f#G" | |
| 855 * print(uri2 == uri3); // prints true. | |
| 856 * | |
| 857 * Using this method can be seen as a shorthand for the `Uri` constructor | |
| 858 * call above, but may also be slightly faster because the parts taken | |
| 859 * from this `Uri` need not be checked for validity again. | |
| 860 */ | |
| 861 Uri replace({String scheme, | |
| 862 String userInfo, | |
| 863 String host, | |
| 864 int port, | |
| 865 String path, | |
| 866 Iterable<String> pathSegments, | |
| 867 String query, | |
| 868 Map<String, String> queryParameters, | |
| 869 String fragment}) { | |
| 870 if (scheme == null) { | |
| 871 scheme = this.scheme; | |
| 872 } else { | |
| 873 scheme = _makeScheme(scheme, scheme.length); | |
| 874 } | |
| 875 if (userInfo == null) { | |
| 876 userInfo = this.userInfo; | |
| 877 } else { | |
| 878 userInfo = _makeUserInfo(userInfo, 0, userInfo.length); | |
| 879 } | |
| 880 if (host == null) { | |
| 881 host = this.host; | |
| 882 } else { | |
| 883 host = _makeHost(host, 0, host.length, false); | |
| 884 } | |
| 885 if (port == null) { | |
| 886 port = this.port; | |
| 887 } | |
| 888 | |
| 889 bool ensureLeadingSlash = (host != "" || scheme == "file"); | |
| 890 if (path == null && pathSegments == null) { | |
| 891 path = this.path; | |
| 892 if (ensureLeadingSlash && !path.isEmpty && !path.startsWith('/')) { | |
| 893 path = "/$path"; | |
| 894 } | |
| 895 } else { | |
| 896 path = _makePath(path, 0, _stringOrNullLength(path), pathSegments, | |
| 897 ensureLeadingSlash); | |
| 898 } | |
| 899 | |
| 900 if (query == null && queryParameters == null) { | |
| 901 query = this.query; | |
| 902 } else { | |
| 903 query = _makeQuery(query, 0, _stringOrNullLength(query), queryParameters); | |
| 904 } | |
| 905 | |
| 906 if (fragment == null) { | |
| 907 fragment = this.fragment; | |
| 908 } else { | |
| 909 fragment = _makeFragment(fragment, 0, fragment.length); | |
| 910 } | |
| 911 | |
| 912 return new Uri._internal( | |
| 913 scheme, userInfo, host, port, path, query, fragment); | |
| 914 } | |
| 915 | |
| 916 /** | |
| 917 * Returns the URI path split into its segments. Each of the | 822 * Returns the URI path split into its segments. Each of the |
| 918 * segments in the returned list have been decoded. If the path is | 823 * segments in the returned list have been decoded. If the path is |
| 919 * empty the empty list will be returned. A leading slash `/` does | 824 * empty the empty list will be returned. A leading slash `/` does |
| 920 * not affect the segments returned. | 825 * not affect the segments returned. |
| 921 * | 826 * |
| 922 * The returned list is unmodifiable and will throw [UnsupportedError] on any | 827 * The returned list is unmodifiable and will throw [UnsupportedError] on any |
| 923 * calls that would mutate it. | 828 * calls that would mutate it. |
| 924 */ | 829 */ |
| 925 List<String> get pathSegments { | 830 List<String> get pathSegments { |
| 926 if (_pathSegments == null) { | 831 if (_pathSegments == null) { |
| (...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2353 0xafff, // 0x30 - 0x3f 1111111111110101 | 2258 0xafff, // 0x30 - 0x3f 1111111111110101 |
| 2354 // @ABCDEFGHIJKLMNO | 2259 // @ABCDEFGHIJKLMNO |
| 2355 0xffff, // 0x40 - 0x4f 1111111111111111 | 2260 0xffff, // 0x40 - 0x4f 1111111111111111 |
| 2356 // PQRSTUVWXYZ _ | 2261 // PQRSTUVWXYZ _ |
| 2357 0x87ff, // 0x50 - 0x5f 1111111111100001 | 2262 0x87ff, // 0x50 - 0x5f 1111111111100001 |
| 2358 // abcdefghijklmno | 2263 // abcdefghijklmno |
| 2359 0xfffe, // 0x60 - 0x6f 0111111111111111 | 2264 0xfffe, // 0x60 - 0x6f 0111111111111111 |
| 2360 // pqrstuvwxyz ~ | 2265 // pqrstuvwxyz ~ |
| 2361 0x47ff]; // 0x70 - 0x7f 1111111111100010 | 2266 0x47ff]; // 0x70 - 0x7f 1111111111100010 |
| 2362 } | 2267 } |
| OLD | NEW |