Closed sethladd closed 11 years ago
I just pulled the master of route, loaded up in Dart Editor, and tried to run the example. This is the failure that I got.
Here's what I had to do to fix it. Is there a way to ignore the host page as a route? The way the editor works, it serves URLs with the entire path:
~/Code/route[master*]$ git diff
diff --git a/example/example.dart b/example/example.dart
index 3f98941..e835043 100644
--- a/example/example.dart
+++ b/example/example.dart
@@ -3,6 +3,7 @@ library example;
import 'dart:html';
import 'package:route/client.dart';
+final example = new UrlPattern('/Users/sethladd/Code/route/example/example.html
final one = new UrlPattern('/one');
final two = new UrlPattern('/two');
@@ -13,6 +14,7 @@ main() {
var router = new Router()
..addHandler(one, showOne)
..addHandler(two, showTwo)
+ ..addHandler(example, (_) => null)
..listen();
}
It looks like Dartium has changed behavior recently and onPopState is called immediately on page load on the page's URL. Before the example never tried to handle the original location of the file, so there was no handler installed.
I'll come up with some fix, but really, the way router is designed to use pushState and onPopState, it's supposed to be used with nice URLs along with some server-side support (to handle the nice URLs on the server-side), not primarily with with fragments like most other routing packages. Another option is that I just add a server to the example.
Ok, fixed the example with your approach but a pattern that will work for any project location.
Thanks for taking a look!
So looks like, to use route, we need to always have a route for the "homepage" of the app.