3.0.3
This commit is contained in:
parent
639d43f42e
commit
0e3e7ee9bb
4 changed files with 21 additions and 19 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
# 3.0.3
|
||||||
|
* Support trailing text after parameters with custom Regexes.
|
||||||
|
|
||||||
# 3.0.2
|
# 3.0.2
|
||||||
* Support leading and trailing text for both `:parameters` and `*`
|
* Support leading and trailing text for both `:parameters` and `*`
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,11 @@ main() {
|
||||||
|
|
||||||
router.get('/wild*', () {});
|
router.get('/wild*', () {});
|
||||||
|
|
||||||
// TODO: Enable trailing after custom RegExp
|
router.get('/ordinal/int:n([0-9]+)st', () {});
|
||||||
// router.get('/ordinal/int:n([0-9]+)st', () {});
|
|
||||||
|
|
||||||
print(router.resolveAbsolute('/whois/~thosakwe').first.allParams);
|
print(router.resolveAbsolute('/whois/~thosakwe').first.allParams);
|
||||||
print(router.resolveAbsolute('/wild_thornberrys').first.route.path);
|
print(router.resolveAbsolute('/wild_thornberrys').first.route.path);
|
||||||
// print(router.resolveAbsolute('/ordinal/1st').first.allParams);
|
print(router.resolveAbsolute('/ordinal/1st').first.allParams);
|
||||||
|
|
||||||
router.get('/users', () {});
|
router.get('/users', () {});
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,11 @@ class RouteGrammar {
|
||||||
match<String>(new RegExp(notSlashRgx)).value((r) => r.span.text);
|
match<String>(new RegExp(notSlashRgx)).value((r) => r.span.text);
|
||||||
|
|
||||||
static final Parser<Match> regExp =
|
static final Parser<Match> regExp =
|
||||||
// TODO: Enable trailing here
|
match<Match>(new RegExp(r'\(([^\n)]+)\)([^/]+)?'))
|
||||||
// match<Match>(new RegExp(r'\(([^)]+)\)([^/]+)?'))
|
|
||||||
match<Match>(new RegExp(r'\(([^)]+)\)'))
|
|
||||||
.value((r) => r.scanner.lastMatch);
|
.value((r) => r.scanner.lastMatch);
|
||||||
|
|
||||||
static final Parser<Match> parameterName = match<Match>(
|
static final Parser<Match> parameterName = match<Match>(
|
||||||
new RegExp('$notSlashRgx?' r':([A-Za-z0-9_]+)' '$notSlashRgx?'))
|
new RegExp('$notSlashRgx?' r':([A-Za-z0-9_]+)' r'([^(/\n])?'))
|
||||||
.value((r) => r.scanner.lastMatch);
|
.value((r) => r.scanner.lastMatch);
|
||||||
|
|
||||||
static final Parser<ParameterSegment> parameterSegment = chain([
|
static final Parser<ParameterSegment> parameterSegment = chain([
|
||||||
|
@ -23,13 +21,16 @@ class RouteGrammar {
|
||||||
]).map((r) {
|
]).map((r) {
|
||||||
var match = r.value[0] as Match;
|
var match = r.value[0] as Match;
|
||||||
var rgxMatch = r.value[2] as Match;
|
var rgxMatch = r.value[2] as Match;
|
||||||
|
|
||||||
|
var pre = match[1] ?? '';
|
||||||
|
var post = match[3] ?? '';
|
||||||
RegExp rgx;
|
RegExp rgx;
|
||||||
|
|
||||||
if (rgxMatch != null) {
|
if (rgxMatch != null) {
|
||||||
rgx = RegExp(rgxMatch[1]);
|
rgx = RegExp('(${rgxMatch[1]})');
|
||||||
var pre = match[1] ?? '';
|
post = (rgxMatch[2] ?? '') + post;
|
||||||
var post = rgxMatch[2] ?? '';
|
}
|
||||||
post += match[3] ?? '';
|
|
||||||
if (pre.isNotEmpty || post.isNotEmpty) {
|
if (pre.isNotEmpty || post.isNotEmpty) {
|
||||||
if (rgx != null) {
|
if (rgx != null) {
|
||||||
var pattern = pre + rgx.pattern + post;
|
var pattern = pre + rgx.pattern + post;
|
||||||
|
@ -38,7 +39,6 @@ class RouteGrammar {
|
||||||
rgx = RegExp('$pre$notSlashRgx$post');
|
rgx = RegExp('$pre$notSlashRgx$post');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var s = new ParameterSegment(match[2], rgx);
|
var s = new ParameterSegment(match[2], rgx);
|
||||||
return r.value[1] == true ? new OptionalSegment(s) : s;
|
return r.value[1] == true ? new OptionalSegment(s) : s;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: angel_route
|
name: angel_route
|
||||||
description: A powerful, isomorphic routing library for Dart. It is mainly used in the Angel framework, but can be used in Flutter and on the Web.
|
description: A powerful, isomorphic routing library for Dart. It is mainly used in the Angel framework, but can be used in Flutter and on the Web.
|
||||||
version: 3.0.2
|
version: 3.0.3
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/angel_route
|
homepage: https://github.com/angel-dart/angel_route
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue