lr-url-parser
Parser that can take placeholders from urls and match them with real urls
Information | - |
---|---|
Code coverage | |
Repo link | lr-client-router |
Dependencies | - |
Size (Browserify, Babel and Gzip) | 777 bytes |
Version | 1.0.0 |
License | MIT |
Usage | guide |
Adding the parser to lagoon road
require('lr-main')('client')
.parser(require('lr-url-parser'));
parser.add(path)
parser.add('blog/:id');
path:string
Add a route including placeholders to the parser, it will use it later for parsing.
parser.parse(path)
parser.parse('blog/1');
// Returns { path : 'blog/:id', parameters : { id : 1 } }
path:string
Parse an incoming route and check if it exists. If it exists it will extract possible parameters and give back the original url. If no match could be made the path is returned in object form like { path : '/original-path' }
.