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 // Frequently used character codes. | 7 // Frequently used character codes. |
8 const int _SPACE = 0x20; | 8 const int _SPACE = 0x20; |
9 const int _PERCENT = 0x25; | 9 const int _PERCENT = 0x25; |
10 const int _PLUS = 0x2B; | 10 const int _PLUS = 0x2B; |
(...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 static String _normalizePath(String path, String scheme, bool hasAuthority) { | 2059 static String _normalizePath(String path, String scheme, bool hasAuthority) { |
2060 if (scheme.isEmpty && !hasAuthority && !path.startsWith('/')) { | 2060 if (scheme.isEmpty && !hasAuthority && !path.startsWith('/')) { |
2061 return _normalizeRelativePath(path); | 2061 return _normalizeRelativePath(path); |
2062 } | 2062 } |
2063 return _removeDotSegments(path); | 2063 return _removeDotSegments(path); |
2064 } | 2064 } |
2065 | 2065 |
2066 static String _makeQuery( | 2066 static String _makeQuery( |
2067 String query, int start, int end, | 2067 String query, int start, int end, |
2068 Map<String, dynamic/*String|Iterable<String>*/> queryParameters) { | 2068 Map<String, dynamic/*String|Iterable<String>*/> queryParameters) { |
2069 if (query == null && queryParameters == null) return null; | 2069 if (query != null) { |
2070 if (query != null && queryParameters != null) { | 2070 if (queryParameters != null) { |
2071 throw new ArgumentError('Both query and queryParameters specified'); | 2071 throw new ArgumentError('Both query and queryParameters specified'); |
| 2072 } |
| 2073 return _normalize(query, start, end, _queryCharTable); |
2072 } | 2074 } |
2073 if (query != null) return _normalize(query, start, end, _queryCharTable); | 2075 if (queryParameters == null) return null; |
2074 | 2076 |
2075 var result = new StringBuffer(); | 2077 var result = new StringBuffer(); |
2076 var separator = ""; | 2078 var separator = ""; |
2077 | 2079 |
2078 void writeParameter(String key, String value) { | 2080 void writeParameter(String key, String value) { |
2079 result.write(separator); | 2081 result.write(separator); |
2080 separator = "&"; | 2082 separator = "&"; |
2081 result.write(Uri.encodeQueryComponent(key)); | 2083 result.write(Uri.encodeQueryComponent(key)); |
2082 if (value != null && value.isNotEmpty) { | 2084 if (value != null && value.isNotEmpty) { |
2083 result.write("="); | 2085 result.write("="); |
(...skipping 2372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4456 int delta = (text.codeUnitAt(start + 4) ^ _COLON) * 3; | 4458 int delta = (text.codeUnitAt(start + 4) ^ _COLON) * 3; |
4457 delta |= text.codeUnitAt(start) ^ 0x64 /*d*/; | 4459 delta |= text.codeUnitAt(start) ^ 0x64 /*d*/; |
4458 delta |= text.codeUnitAt(start + 1) ^ 0x61 /*a*/; | 4460 delta |= text.codeUnitAt(start + 1) ^ 0x61 /*a*/; |
4459 delta |= text.codeUnitAt(start + 2) ^ 0x74 /*t*/; | 4461 delta |= text.codeUnitAt(start + 2) ^ 0x74 /*t*/; |
4460 delta |= text.codeUnitAt(start + 3) ^ 0x61 /*a*/; | 4462 delta |= text.codeUnitAt(start + 3) ^ 0x61 /*a*/; |
4461 return delta; | 4463 return delta; |
4462 } | 4464 } |
4463 | 4465 |
4464 /// Helper function returning the length of a string, or `0` for `null`. | 4466 /// Helper function returning the length of a string, or `0` for `null`. |
4465 int _stringOrNullLength(String s) => (s == null) ? 0 : s.length; | 4467 int _stringOrNullLength(String s) => (s == null) ? 0 : s.length; |
OLD | NEW |