DEV Community

loading...

Help Improve my Simple Open Source JavaScript Router

mckabue profile image Kabue Charles ・1 min read

i would love your opinion on this simple and dynamic JavaScript router that i use for my Single Page Application. I find it easy, simple, light and effective.

/*
 * USAGE
 * https://jsfiddle.net/mckabue/knwvsy3t/18/
 * 
 * var $router = ROUTER(['/home/{tag}?gh={gh}']);
 * var $match = $router.match('/home/a tag?gh=dfe');
 * console.log($match); //{tag: "a tag", gh: "dfe"}
 * 
 */

https://jsfiddle.net/mckabue/knwvsy3t/18/

Discussion (3)

pic
Editor guide
Collapse
nhh profile image
Niklas

You could write it in typescript, abstract things in classes and improve readability 😊

Collapse
mckabue profile image
Kabue Charles Author

Thanks... Will definitely do that

Collapse
nhh profile image
Niklas

Typescript is f*ing awesome 😁