1.0.8
This commit is contained in:
parent
13cd62a6f0
commit
57b2bdff87
6 changed files with 50 additions and 5 deletions
|
@ -43,6 +43,7 @@ abstract class BrowserRouter extends Router {
|
|||
}
|
||||
|
||||
abstract class _BrowserRouterImpl extends Router implements BrowserRouter {
|
||||
bool _listening = false;
|
||||
Route _current;
|
||||
StreamController<RoutingResult> _onResolve =
|
||||
new StreamController<RoutingResult>();
|
||||
|
@ -83,6 +84,16 @@ abstract class _BrowserRouterImpl extends Router implements BrowserRouter {
|
|||
$a.attributes['dynamic'] = 'true';
|
||||
}
|
||||
}
|
||||
|
||||
void _listen();
|
||||
|
||||
@override
|
||||
void listen() {
|
||||
if (_listening)
|
||||
throw new StateError('The router is already listening for page changes.');
|
||||
_listening = true;
|
||||
_listen();
|
||||
}
|
||||
}
|
||||
|
||||
class _HashRouter extends _BrowserRouterImpl {
|
||||
|
@ -121,7 +132,7 @@ class _HashRouter extends _BrowserRouterImpl {
|
|||
}
|
||||
|
||||
@override
|
||||
void listen() {
|
||||
void _listen() {
|
||||
window.onHashChange.listen(handleHash);
|
||||
handleHash();
|
||||
}
|
||||
|
@ -184,7 +195,7 @@ class _PushStateRouter extends _BrowserRouterImpl {
|
|||
}
|
||||
|
||||
@override
|
||||
void listen() {
|
||||
void _listen() {
|
||||
window.onPopState.listen((e) {
|
||||
handleState(e.state);
|
||||
});
|
||||
|
|
|
@ -354,7 +354,7 @@ class Route {
|
|||
for (int i = 0; i < matches.length && i < values.length; i++) {
|
||||
Match match = matches.elementAt(i);
|
||||
String paramName = match.group(1);
|
||||
String value = values.elementAt(i);
|
||||
String value = Uri.decodeComponent(values.elementAt(i));
|
||||
// _printDebug('Setting param "$paramName" to "$value"...');
|
||||
result[paramName] = value;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,8 @@ class Router {
|
|||
: segments.join('/');
|
||||
}
|
||||
|
||||
/// Assigns a middleware to a name for convenience.
|
||||
/// Manually assign via [requestMiddleware] instead.
|
||||
@deprecated
|
||||
registerMiddleware(String name, middleware) {
|
||||
requestMiddleware[name] = middleware;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: angel_route
|
||||
description: A powerful, isomorphic routing library for Dart.
|
||||
version: 1.0.7
|
||||
version: 1.0.8
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_route
|
||||
dev_dependencies:
|
||||
|
|
15
test/root_test.dart
Normal file
15
test/root_test.dart
Normal file
|
@ -0,0 +1,15 @@
|
|||
import 'package:angel_route/angel_route.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('resolve / on /', () {
|
||||
var router = new Router()
|
||||
..group('/', (router) {
|
||||
router.group('/', (router) {
|
||||
router.get('/', 'ok');
|
||||
});
|
||||
});
|
||||
|
||||
expect(router.resolveAbsolute('/'), isNotNull);
|
||||
});
|
||||
}
|
18
test/uri_decode_test.dart
Normal file
18
test/uri_decode_test.dart
Normal file
|
@ -0,0 +1,18 @@
|
|||
import 'package:angel_route/angel_route.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('uri params decoded', () {
|
||||
var router = new Router()..get('/a/:a/b/:b', '');
|
||||
|
||||
var encoded =
|
||||
'/a/' + Uri.encodeComponent('<<<') + '/b/' + Uri.encodeComponent('???');
|
||||
print(encoded);
|
||||
var result = router.resolveAbsolute(encoded);
|
||||
print(result.allParams);
|
||||
expect(result.allParams, {
|
||||
'a': '<<<',
|
||||
'b': '???',
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue