Chromium Code Reviews| Index: pkg/path/lib/src/style/posix.dart |
| diff --git a/pkg/path/lib/src/style/posix.dart b/pkg/path/lib/src/style/posix.dart |
| index b8b82b406d33f31a08d5c4a05c67b86dbdbc4b2f..30278245400909ce685b18e2ccc60c16b3fa3c76 100644 |
| --- a/pkg/path/lib/src/style/posix.dart |
| +++ b/pkg/path/lib/src/style/posix.dart |
| @@ -30,8 +30,14 @@ class PosixStyle extends InternalStyle { |
| bool needsSeparator(String path) => |
| path.isNotEmpty && !isSeparator(path.codeUnitAt(path.length - 1)); |
| + int rootLength(String path) { |
| + if (path.isNotEmpty && isSeparator(path.codeUnitAt(0))) return 1; |
| + return 0; |
| + } |
| + |
| String getRoot(String path) { |
| - if (path.isNotEmpty && isSeparator(path.codeUnitAt(0))) return '/'; |
| + int length = rootLength(path); |
|
Bob Nystrom
2014/08/04 17:17:32
int -> var, here and elsewhere. We don't type anno
Anders Johnsen
2014/08/05 08:57:13
Done.
|
| + if (length > 0) return path.substring(0, length); |
| return null; |
| } |