DEV Community

Kabue Charles
Kabue Charles

Posted on

Help Improve my Simple Open Source JavaScript Router

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"}
 * 
 */
Enter fullscreen mode Exit fullscreen mode

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

Top comments (3)

Collapse
 
nhh profile image
Niklas

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

Collapse
 
mckabue profile image
Kabue Charles

Thanks... Will definitely do that

Collapse
 
nhh profile image
Niklas

Typescript is f*ing awesome 😁