3 ms·
> includes within includes . . . global variables Yeah, that's a pain. You have to exercise a little discipline. Of course none of my code has that ;) With ha
by combatentropy 9y ago
> includes within includes . . . global variables
Yeah, that's a pain. You have to exercise a little discipline. Of course none of my code has that ;)
With hand-typed routing, can't you accidentally define two routes that overlap, so some URLs could match both? The only reason it goes to one and not the other is something random like the order the routes are defined in the file? Like if you defined this route:
/a/b/c
Then you slept, added a bunch of code, came back in three months and put this in:
/a/*/c
Now you have two routes that match the same URL. And maybe they're separated by several lines of code, so that the mistake is hard to spot.
You can't do that with a filesystem, put two files in the same place.
- krapp 9y ago> The only reason it goes to one and not the other is something random like the order the routes are defined in the file? To be fair, that's not random, that's pretty explicit. And if you're optimizing for speed, short circuiting at the first match is a good idea. But if you're using a router, chances are you're passing the segments as arguments to some function or method anyway, so route /a/*/c and /a/b/c should both wind up returning the same content if the second segment in both cases is 'b'.