| OLD | NEW |
| (Empty) | |
| 1 library url_matcher; |
| 2 |
| 3 import 'package:unittest/matcher.dart'; |
| 4 |
| 5 /** |
| 6 * A reversible URL matcher interface. |
| 7 */ |
| 8 abstract class UrlMatcher { |
| 9 |
| 10 /** |
| 11 * Attempts to match a given URL. If match is successul then returns an |
| 12 * instance or [UrlMatch], otherwise returns [null]. |
| 13 */ |
| 14 UrlMatch match(String url); |
| 15 |
| 16 /** |
| 17 * Reverses (reconstructs) a URL from optionally provided parameters map |
| 18 * and a tail. |
| 19 */ |
| 20 String reverse({Map parameters, String tail}); |
| 21 |
| 22 /** |
| 23 * Returns a list of named parameters in the URL. |
| 24 */ |
| 25 List<String> urlParameterNames(); |
| 26 } |
| 27 |
| 28 /** |
| 29 * Object representing a successul URL match. |
| 30 */ |
| 31 class UrlMatch { |
| 32 |
| 33 /// Matched section of the URL |
| 34 final String match; |
| 35 |
| 36 /// Remaining unmatched suffix |
| 37 final String tail; |
| 38 |
| 39 /// |
| 40 final Map parameters; |
| 41 |
| 42 UrlMatch(this.match, this.tail, this.parameters); |
| 43 |
| 44 bool operator ==(o) { |
| 45 if (!(o is UrlMatch)) { |
| 46 return false; |
| 47 } |
| 48 return o.match == match && o.tail == tail && |
| 49 equals(o.parameters, 1).matches(parameters, null); |
| 50 } |
| 51 |
| 52 String toString() { |
| 53 return '{$match, $tail, $parameters}'; |
| 54 } |
| 55 } |
| OLD | NEW |