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

Unified Diff: pkg/path/lib/src/style/posix.dart

Issue 309803003: Avoid using RegExps in path to work around issue 19090. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 7 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 | « pkg/path/lib/src/parsed_path.dart ('k') | pkg/path/lib/src/style/url.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e0b601743c743b829aa817fc5721e3128cadb9a9..b8b82b406d33f31a08d5c4a05c67b86dbdbc4b2f 100644
--- a/pkg/path/lib/src/style/posix.dart
+++ b/pkg/path/lib/src/style/posix.dart
@@ -4,6 +4,7 @@
library path.style.posix;
+import '../characters.dart' as chars;
import '../parsed_path.dart';
import '../internal_style.dart';
@@ -13,9 +14,28 @@ class PosixStyle extends InternalStyle {
final name = 'posix';
final separator = '/';
+ final separators = const ['/'];
+
+ // Deprecated properties.
+
final separatorPattern = new RegExp(r'/');
final needsSeparatorPattern = new RegExp(r'[^/]$');
final rootPattern = new RegExp(r'^/');
+ final relativeRootPattern = null;
+
+ bool containsSeparator(String path) => path.contains('/');
+
+ bool isSeparator(int codeUnit) => codeUnit == chars.SLASH;
+
+ bool needsSeparator(String path) =>
+ path.isNotEmpty && !isSeparator(path.codeUnitAt(path.length - 1));
+
+ String getRoot(String path) {
+ if (path.isNotEmpty && isSeparator(path.codeUnitAt(0))) return '/';
+ return null;
+ }
+
+ String getRelativeRoot(String path) => null;
String pathFromUri(Uri uri) {
if (uri.scheme == '' || uri.scheme == 'file') {
« no previous file with comments | « pkg/path/lib/src/parsed_path.dart ('k') | pkg/path/lib/src/style/url.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698