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

Unified Diff: third_party/pkg/route_hierarchical/lib/url_matcher.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 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
Index: third_party/pkg/route_hierarchical/lib/url_matcher.dart
diff --git a/third_party/pkg/route_hierarchical/lib/url_matcher.dart b/third_party/pkg/route_hierarchical/lib/url_matcher.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9cec1f91d9734410fa32354a852fedb508c32800
--- /dev/null
+++ b/third_party/pkg/route_hierarchical/lib/url_matcher.dart
@@ -0,0 +1,55 @@
+library url_matcher;
+
+import 'package:unittest/matcher.dart';
+
+/**
+ * A reversible URL matcher interface.
+ */
+abstract class UrlMatcher {
+
+ /**
+ * Attempts to match a given URL. If match is successul then returns an
+ * instance or [UrlMatch], otherwise returns [null].
+ */
+ UrlMatch match(String url);
+
+ /**
+ * Reverses (reconstructs) a URL from optionally provided parameters map
+ * and a tail.
+ */
+ String reverse({Map parameters, String tail});
+
+ /**
+ * Returns a list of named parameters in the URL.
+ */
+ List<String> urlParameterNames();
+}
+
+/**
+ * Object representing a successul URL match.
+ */
+class UrlMatch {
+
+ /// Matched section of the URL
+ final String match;
+
+ /// Remaining unmatched suffix
+ final String tail;
+
+ ///
+ final Map parameters;
+
+ UrlMatch(this.match, this.tail, this.parameters);
+
+ bool operator ==(o) {
+ if (!(o is UrlMatch)) {
+ return false;
+ }
+ return o.match == match && o.tail == tail &&
+ equals(o.parameters, 1).matches(parameters, null);
+ }
+
+ String toString() {
+ return '{$match, $tail, $parameters}';
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698