From 555b028ac1a44be410e4cd47c78a65e5ffae44b3 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 3 Jun 2018 21:46:44 -0400 Subject: [PATCH] 2.0.5 --- .gitignore | 4 ++++ .idea/angel_route.iml | 16 ------------- .idea/misc.xml | 26 ++-------------------- .idea/modules.xml | 2 +- .idea/runConfigurations/All_Tests.xml | 7 ------ .idea/runConfigurations/Navigate_Tests.xml | 6 ----- .idea/runConfigurations/Params_Tests.xml | 6 ----- .idea/runConfigurations/Server_Tests.xml | 6 ----- .travis.yml | 5 ++++- CHANGELOG.md | 2 ++ lib/src/grammar.dart | 8 +++++-- lib/src/route.dart | 2 +- lib/src/router.dart | 4 ++-- pubspec.yaml | 10 ++++++--- test/server_test.dart | 16 ++++++------- 15 files changed, 37 insertions(+), 83 deletions(-) delete mode 100644 .idea/angel_route.iml delete mode 100644 .idea/runConfigurations/All_Tests.xml delete mode 100644 .idea/runConfigurations/Navigate_Tests.xml delete mode 100644 .idea/runConfigurations/Params_Tests.xml delete mode 100644 .idea/runConfigurations/Server_Tests.xml create mode 100644 CHANGELOG.md diff --git a/.gitignore b/.gitignore index efa8ebc7..718b4b01 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,7 @@ crashlytics.properties crashlytics-build.properties fabric.properties + +.idea +.dart_tool +*.iml \ No newline at end of file diff --git a/.idea/angel_route.iml b/.idea/angel_route.iml deleted file mode 100644 index eae13016..00000000 --- a/.idea/angel_route.iml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index c65900a0..639900d1 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,28 +1,6 @@ - - - - - - - - - - - General - - - XPath - - - - - AngularJS - - - - + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 51fa8762..b6a601b4 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/runConfigurations/All_Tests.xml b/.idea/runConfigurations/All_Tests.xml deleted file mode 100644 index ac11209e..00000000 --- a/.idea/runConfigurations/All_Tests.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Navigate_Tests.xml b/.idea/runConfigurations/Navigate_Tests.xml deleted file mode 100644 index 40a1098f..00000000 --- a/.idea/runConfigurations/Navigate_Tests.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Params_Tests.xml b/.idea/runConfigurations/Params_Tests.xml deleted file mode 100644 index dbb5cceb..00000000 --- a/.idea/runConfigurations/Params_Tests.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Server_Tests.xml b/.idea/runConfigurations/Server_Tests.xml deleted file mode 100644 index d2df89e9..00000000 --- a/.idea/runConfigurations/Server_Tests.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index de2210c9..a9e2c109 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,4 @@ -language: dart \ No newline at end of file +language: dart +dart: + - dev + - stable \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..4b925280 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +# 2.0.5 +* Patch to work with `combinator@1.0.0`. \ No newline at end of file diff --git a/lib/src/grammar.dart b/lib/src/grammar.dart index 6c061e00..10c67b3c 100644 --- a/lib/src/grammar.dart +++ b/lib/src/grammar.dart @@ -1,9 +1,11 @@ part of angel_route.src.router; class RouteGrammar { + static final RegExp rgx = new RegExp(r'\((.+)\)'); static final Parser notSlash = match(new RegExp(r'[^/]+')).value((r) => r.span.text); - static final Parser regExp = new _RegExpParser(); + static final Parser regExp = + match(rgx).map((r) => new RegExp(r.scanner.lastMatch[1])); static final Parser parameterName = match(new RegExp(r':([A-Za-z0-9_]+)')) .value((r) => r.span.text.substring(1)); @@ -32,6 +34,7 @@ class RouteGrammar { .surroundedBy(match('/').star().opt()); } +/* class _RegExpParser extends Parser { static final RegExp rgx = new RegExp(r'\((.+)\)'); @@ -41,7 +44,7 @@ class _RegExpParser extends Parser { return new ParseResult(this, true, [], span: scanner.lastSpan, value: new RegExp(scanner.lastMatch[1])); } -} +}*/ class RouteDefinition { final List segments; @@ -66,6 +69,7 @@ class RouteDefinition { abstract class RouteSegment { Parser> compile(bool isLast); + Parser> compileNext( Parser> p, bool isLast); } diff --git a/lib/src/route.dart b/lib/src/route.dart index 5ce9ec7e..20208b39 100644 --- a/lib/src/route.dart +++ b/lib/src/route.dart @@ -14,7 +14,7 @@ class Route { : _routeDefinition = RouteGrammar.routeDefinition .parse(new SpanScanner(path.replaceAll(_straySlashes, ''))) .value { - if (_routeDefinition.segments.isEmpty) _parser = match('').value((r) => {}); + if (_routeDefinition?.segments?.isNotEmpty != true) _parser = match('').value((r) => {}); } factory Route.join(Route a, Route b) { diff --git a/lib/src/router.dart b/lib/src/router.dart index fb26c83c..434ff476 100644 --- a/lib/src/router.dart +++ b/lib/src/router.dart @@ -10,12 +10,12 @@ part 'symlink_route.dart'; part 'route.dart'; part 'routing_result.dart'; -final RegExp _param = new RegExp(r':([A-Za-z0-9_]+)(\((.+)\))?'); +/*final RegExp _param = new RegExp(r':([A-Za-z0-9_]+)(\((.+)\))?'); final RegExp _rgxEnd = new RegExp(r'\$+$'); final RegExp _rgxStart = new RegExp(r'^\^+'); final RegExp _rgxStraySlashes = new RegExp(r'(^((\\+/)|(/))+)|(((\\+/)|(/))+$)'); -final RegExp _slashDollar = new RegExp(r'/+\$'); +final RegExp _slashDollar = new RegExp(r'/+\$');*/ final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)'); /// An abstraction over complex [Route] trees. Use this instead of the raw API. :) diff --git a/pubspec.yaml b/pubspec.yaml index ef317b53..79f63096 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,13 +1,17 @@ name: angel_route description: A powerful, isomorphic routing library for Dart. -version: 2.0.4 +version: 2.0.5 author: Tobe O homepage: https://github.com/angel-dart/angel_route environment: - sdk: ">=1.19.0" + sdk: ">=1.19.0 <3.0.0" dependencies: - combinator: ^1.0.0-beta + combinator: ^1.0.0 + meta: ^1.0.0 + path: ^1.0.0 + string_scanner: ^1.0.0 dev_dependencies: browser: ">=0.10.0 < 0.11.0" + dart2_constant: ^1.0.0 http: ">=0.11.3 <0.12.0" test: ">=0.12.15 <0.13.0" \ No newline at end of file diff --git a/test/server_test.dart b/test/server_test.dart index b7e6823c..5a2ee99d 100644 --- a/test/server_test.dart +++ b/test/server_test.dart @@ -1,6 +1,6 @@ -import 'dart:convert'; import 'dart:io'; import 'package:angel_route/angel_route.dart'; +import 'package:dart2_constant/convert.dart'; import 'package:http/http.dart' as http; import 'package:test/test.dart'; @@ -27,7 +27,7 @@ main() { router.group('/people', (router) { router.get('/', (req, res) { - res.write(JSON.encode(people)); + res.write(json.encode(people)); return false; }); @@ -35,14 +35,14 @@ main() { router.get('/', (req, res) { // In a real application, we would take the param, // but not here... - res.write(JSON.encode(people.first)); + res.write(json.encode(people.first)); return false; }); router.get('/name', (req, res) { // In a real application, we would take the param, // but not here... - res.write(JSON.encode(people.first['name'])); + res.write(json.encode(people.first['name'])); return false; }); }); @@ -76,7 +76,7 @@ main() { client = new http.Client(); router.dumpTree(); - server = await HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 0); + server = await HttpServer.bind('127.0.0.1', 0); url = 'http://${server.address.address}:${server.port}'; server.listen((req) async { @@ -129,20 +129,20 @@ main() { test('root', () async { final res = await client.get('$url/people'); print('Response: ${res.body}'); - expect(JSON.decode(res.body), equals(people)); + expect(json.decode(res.body), equals(people)); }); group('param', () { test('root', () async { final res = await client.get('$url/people/0'); print('Response: ${res.body}'); - expect(JSON.decode(res.body), equals(people.first)); + expect(json.decode(res.body), equals(people.first)); }); test('path', () async { final res = await client.get('$url/people/0/name'); print('Response: ${res.body}'); - expect(JSON.decode(res.body), equals(people.first['name'])); + expect(json.decode(res.body), equals(people.first['name'])); }); }); });