Skip to content

Instantly share code, notes, and snippets.

@egoist egoist/path-extract.js
Last active Feb 9, 2017

Embed
What would you like to do?
const extract = require('path-extract')
const params = extract('/user/:username', '/user/egoist')
console.log(params)
//=>
{
username: 'egoist'
}
import routage from 'routage'
const router = routage([
{
path: '/',
render() {
console.log('home')
}
},
{
path: '/about',
render() {
console.log('about')
}
},
{
path: '/user/:username',
render(params) {
console.log(`Hi ${params.username}`)
}
}
])
router.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.