Comments (5)
I was thinking of doing this in rlite. I wrote this: https://github.com/chrisdavies/cljs-router
Which has this feature via this syntax: users/*name
Aso, there's another bug w/ rlite that cljs-router doesn't have, which (if I remember right) is that rlite won't match this:
// Given these two registrations:
const route = rlite(notFound, {
'foo/bar/baz': someHandler,
'foo/:name/bing': someOtherHandler
});
// This won't match route('foo/bar/bing');
So, I will add rlite to my queue and get these in.
from rlite.
Sounds good about the *
token. I can confirm that bug:
(require('.')(() => console.log('404'), {
'foo/bar/baz': () => console.log('1'),
'foo/:name/bing': () => console.log('2'),
}))('foo/bar/bing');
prints 404
.
from rlite.
Fixed the bug and added wildcard support.
There is a drawback to these changes, which is that they now require recursion where the previous version didn't. It also added around 100 bytes to the min/gzipped size. It seems like a worthwhile trade-off, though.
If you're using this on the server-side, though, it's possible for this library to cause a stack-overflow now, given a long, malicious URL. So, routes should be matched in a try/catch in that case.
from rlite.
Thanks! I'm using it purely on client side, so I hope I'm safe :)
from rlite.
Oh, and I think Node.js should not be able to trigger a stack overflow via recursion. There's two limits in place, first is the 80kB maximum HTTP header size:
https://github.com/nodejs/node/blob/master/deps/http_parser/http_parser.h#L64
And secondly, there's v8's maximum call stack limit that depends on stack size, thought tail call optimization might change that:
http://2ality.com/2014/04/call-stack-size.html
from rlite.
Related Issues (20)
- Test issue
- Routes with multiple parameters HOT 1
- Typo in the readme.md HOT 1
- This is the best router HOT 1
- Middleware support HOT 1
- Cannot read property 'define' of undefined HOT 3
- Hashbang/Shebang support HOT 1
- Uncaught ReferenceError: rlite is not defined HOT 6
- Not a flexible language for setting a template HOT 3
- Error when matching conflicting URLs in one edgecase
- Possible wildcard match bug HOT 7
- Percent signs in request results in "URI malformed" error HOT 2
- Dumb question HOT 1
- support history api? HOT 3
- Can't load / use rlite HOT 3
- Example without hash based routing
- Implement Hash routing but leaving the root location alone.
- Publish to npm? HOT 4
- Uppercase routes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rlite.