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

Unified Diff: pkg/path/lib/path.dart

Issue 11876012: Fix minor path handling issue in path package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/path/test/path_windows_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/path/lib/path.dart
diff --git a/pkg/path/lib/path.dart b/pkg/path/lib/path.dart
index cc882f47f94ec460de01cea5264018b7ff8a941a..4b9b7030bb093a623e190659c1ac3742eb0bdb4d 100644
--- a/pkg/path/lib/path.dart
+++ b/pkg/path/lib/path.dart
@@ -438,10 +438,14 @@ class Builder {
// If the root prefixes don't match (for example, different drive letters
// on Windows), then there is no relative path, so just return the absolute
- // one.
- // TODO(rnystrom): Drive letters are case-insentive on Windows. Should
- // handle "C:\" and "c:\" being the same root.
- if (fromParsed.root != pathParsed.root) return pathParsed.toString();
+ // one. In Windows, drive letters are case-insenstive and we allow
+ // calculation of relative paths, even if a path has not been normalized.
+ if (fromParsed.root != pathParsed.root &&
+ ((fromParsed.root == null || pathParsed.root == null) ||
Jennifer Messerly 2013/01/12 23:36:01 looks like an extra space after == ?
Emily Fortuna 2013/01/12 23:43:32 Done.
+ fromParsed.root.toLowerCase().replaceAll('/', '\\') !=
+ pathParsed.root.toLowerCase().replaceAll('/', '\\'))) {
+ return pathParsed.toString();
+ }
// Strip off their common prefix.
while (fromParsed.parts.length > 0 && pathParsed.parts.length > 0 &&
@@ -644,6 +648,10 @@ class _ParsedPath {
parts = newParts;
separators = newSeparators;
+ // Normalize the Windows root if needed.
+ if (root != null && !root.startsWith('//') && style == Style.windows) {
Jennifer Messerly 2013/01/12 23:36:01 I think we do want to normalize UNC to r"\\" as we
Jennifer Messerly 2013/01/12 23:37:50 oops wrong link. this one is better: http://en.wik
Emily Fortuna 2013/01/12 23:43:32 Done.
+ root = root.replaceAll('/', '\\');
+ }
removeTrailingSeparators();
}
« no previous file with comments | « no previous file | pkg/path/test/path_windows_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698