Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: sdk/lib/core/uri.dart

Issue 23522030: Don't use Uri's isAbsolute to detect if the path segment is absolute, in toFilePath. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, as specified by RFC-3986, http://tools.ietf.org/html/rfc3986. 8 * A parsed URI, as specified by RFC-3986, http://tools.ietf.org/html/rfc3986.
9 */ 9 */
10 class Uri { 10 class Uri {
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 } 964 }
965 965
966 String _toFilePath() { 966 String _toFilePath() {
967 if (host != "") { 967 if (host != "") {
968 throw new UnsupportedError( 968 throw new UnsupportedError(
969 "Cannot extract a non-Windows file path from a file URI " 969 "Cannot extract a non-Windows file path from a file URI "
970 "with an authority"); 970 "with an authority");
971 } 971 }
972 _checkNonWindowsPathReservedCharacters(pathSegments, false); 972 _checkNonWindowsPathReservedCharacters(pathSegments, false);
973 var result = new StringBuffer(); 973 var result = new StringBuffer();
974 if (isAbsolute) result.write("/"); 974 if (_isPathAbsolute) result.write("/");
975 result.writeAll(pathSegments, "/"); 975 result.writeAll(pathSegments, "/");
976 return result.toString(); 976 return result.toString();
977 } 977 }
978 978
979 String _toWindowsFilePath() { 979 String _toWindowsFilePath() {
980 bool hasDriveLetter = false; 980 bool hasDriveLetter = false;
981 var segments = pathSegments; 981 var segments = pathSegments;
982 if (segments.length > 0 && 982 if (segments.length > 0 &&
983 segments[0].length == 2 && 983 segments[0].length == 2 &&
984 segments[0].codeUnitAt(1) == _COLON) { 984 segments[0].codeUnitAt(1) == _COLON) {
985 _checkWindowsDriveLetter(segments[0].codeUnitAt(0), false); 985 _checkWindowsDriveLetter(segments[0].codeUnitAt(0), false);
986 _checkWindowsPathReservedCharacters(segments, false, 1); 986 _checkWindowsPathReservedCharacters(segments, false, 1);
987 hasDriveLetter = true; 987 hasDriveLetter = true;
988 } else { 988 } else {
989 _checkWindowsPathReservedCharacters(segments, false); 989 _checkWindowsPathReservedCharacters(segments, false);
990 } 990 }
991 var result = new StringBuffer(); 991 var result = new StringBuffer();
992 if (isAbsolute && !hasDriveLetter) result.write("\\"); 992 if (_isPathAbsolute && !hasDriveLetter) result.write("\\");
993 if (host != "") { 993 if (host != "") {
994 result.write("\\"); 994 result.write("\\");
995 result.write(host); 995 result.write(host);
996 result.write("\\"); 996 result.write("\\");
997 } 997 }
998 result.writeAll(segments, "\\"); 998 result.writeAll(segments, "\\");
999 if (hasDriveLetter && segments.length == 1) result.write("\\"); 999 if (hasDriveLetter && segments.length == 1) result.write("\\");
1000 return result.toString(); 1000 return result.toString();
1001 } 1001 }
1002 1002
1003 bool get _isPathAbsolute {
1004 if (path == null || path.isEmpty) return false;
1005 return path.startsWith('/');
1006 }
1007
1003 void _writeAuthority(StringSink ss) { 1008 void _writeAuthority(StringSink ss) {
1004 _addIfNonEmpty(ss, userInfo, userInfo, "@"); 1009 _addIfNonEmpty(ss, userInfo, userInfo, "@");
1005 ss.write(_host == null ? "null" : _host); 1010 ss.write(_host == null ? "null" : _host);
1006 if (port != 0) { 1011 if (port != 0) {
1007 ss.write(":"); 1012 ss.write(":");
1008 ss.write(port.toString()); 1013 ss.write(port.toString());
1009 } 1014 }
1010 } 1015 }
1011 1016
1012 String toString() { 1017 String toString() {
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 void clear() { 1640 void clear() {
1636 throw new UnsupportedError("Cannot modify an unmodifiable map"); 1641 throw new UnsupportedError("Cannot modify an unmodifiable map");
1637 } 1642 }
1638 void forEach(void f(K key, V value)) => _map.forEach(f); 1643 void forEach(void f(K key, V value)) => _map.forEach(f);
1639 Iterable<K> get keys => _map.keys; 1644 Iterable<K> get keys => _map.keys;
1640 Iterable<V> get values => _map.values; 1645 Iterable<V> get values => _map.values;
1641 int get length => _map.length; 1646 int get length => _map.length;
1642 bool get isEmpty => _map.isEmpty; 1647 bool get isEmpty => _map.isEmpty;
1643 bool get isNotEmpty => _map.isNotEmpty; 1648 bool get isNotEmpty => _map.isNotEmpty;
1644 } 1649 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698