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

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: 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') | pkg/path/test/windows_test.dart » ('J')
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..07bded709d6a36558fc8e7595ae34f7013c89b54 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.toString());
Bob Nystrom 2013/11/14 17:05:08 The toString() isn't needed here.
nweiz 2013/11/14 21:10:17 Done.
} else if (this.isAbsolute(part)) {
isAbsoluteAndNotRootRelative = !this.isRootRelative(part);
// An absolute path discards everything before it.
@@ -982,6 +985,7 @@ class _WindowsStyle extends Style {
final separatorPattern = new RegExp(r'[/\\]');
final needsSeparatorPattern = new RegExp(r'[^/\\]$');
final rootPattern = new RegExp(r'^(\\\\[^\\]+\\[^\\/]+|[a-zA-Z]:[/\\])');
+ final relativeRootPattern = new RegExp(r"^[/\\](?![/\\])");
Bob Nystrom 2013/11/14 17:05:08 Doc comment for this please. Regexen are opaque.
nweiz 2013/11/14 21:10:17 Done.
String pathFromUri(Uri uri) {
if (uri.scheme != '' && uri.scheme != 'file') {
« no previous file with comments | « no previous file | pkg/path/test/windows_test.dart » ('j') | pkg/path/test/windows_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698