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

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..f27d558790a198fee5916fb15f14db2a90c1bf68 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) ||
+ 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 && style == Style.windows) {
+ 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