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

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

Issue 439223002: Add InternalStyle:rootLength to implement isAbsolute and rootPrefix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review update. Created 6 years, 4 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/lib/src/internal_style.dart » ('j') | pkg/path/lib/src/internal_style.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/path/lib/src/context.dart
diff --git a/pkg/path/lib/src/context.dart b/pkg/path/lib/src/context.dart
index 7a88909f5f48e342ef258ca42c816c55b4079a70..e9237a2ba0216125bc74c9f1f8c0a7eaf4f235f5 100644
--- a/pkg/path/lib/src/context.dart
+++ b/pkg/path/lib/src/context.dart
@@ -148,10 +148,7 @@ class Context {
/// context.rootPrefix('path/to/foo'); // -> ''
/// context.rootPrefix('http://dartlang.org/path/to/foo');
/// // -> 'http://dartlang.org'
- String rootPrefix(String path) {
- var root = _parse(path).root;
- return root == null ? '' : root;
- }
+ String rootPrefix(String path) => path.substring(0, style.rootLength(path));
/// Returns `true` if [path] is an absolute path and `false` if it is a
/// relative path.
@@ -165,7 +162,7 @@ class Context {
/// relative to the root of the current URL. Since root-relative paths are
/// still absolute in every other sense, [isAbsolute] will return true for
/// them. They can be detected using [isRootRelative].
- bool isAbsolute(String path) => _parse(path).isAbsolute;
+ bool isAbsolute(String path) => style.rootLength(path) > 0;
/// Returns `true` if [path] is a relative path and `false` if it is absolute.
/// On POSIX systems, absolute paths start with a `/` (forward slash). On
@@ -181,7 +178,7 @@ class Context {
/// them. They can be detected using [isRootRelative].
///
/// No POSIX and Windows paths are root-relative.
- bool isRootRelative(String path) => _parse(path).isRootRelative;
+ bool isRootRelative(String path) => style.isRootRelative(path);
/// Joins the given path parts into a single path. Example:
///
« no previous file with comments | « no previous file | pkg/path/lib/src/internal_style.dart » ('j') | pkg/path/lib/src/internal_style.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698