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

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

Issue 68503011: Support root-relative paths on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 7 years, 1 month 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/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 3c5f51eb3ea967285dfa8aee4586088c21e8a588..5d49097818b5fa82fac63805f9f225fa569bf7b2 100644
--- a/pkg/path/lib/path.dart
+++ b/pkg/path/lib/path.dart
@@ -560,10 +560,13 @@ class Builder {
if (this.isRootRelative(part) && isAbsoluteAndNotRootRelative) {
// If the new part is root-relative, it preserves the previous root but
// replaces the path after it.
- var oldRoot = this.rootPrefix(buffer.toString());
+ var parsed = _parse(part);
+ parsed.root = this.rootPrefix(buffer.toString());
+ if (parsed.root.contains(style.needsSeparatorPattern)) {
+ parsed.separators[0] = style.separator;
+ }
buffer.clear();
- buffer.write(oldRoot);
- buffer.write(part);
+ buffer.write(parsed);
} else if (this.isAbsolute(part)) {
isAbsoluteAndNotRootRelative = !this.isRootRelative(part);
// An absolute path discards everything before it.
@@ -983,6 +986,10 @@ class _WindowsStyle extends Style {
final needsSeparatorPattern = new RegExp(r'[^/\\]$');
final rootPattern = new RegExp(r'^(\\\\[^\\]+\\[^\\/]+|[a-zA-Z]:[/\\])');
+ // Matches a back or forward slash that's not followed by another back or
+ // forward slash.
+ final relativeRootPattern = new RegExp(r"^[/\\](?![/\\])");
+
String pathFromUri(Uri uri) {
if (uri.scheme != '' && uri.scheme != 'file') {
throw new ArgumentError("Uri $uri must have scheme 'file:'.");
« no previous file with comments | « no previous file | pkg/path/test/windows_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698