page-path-builder
Version:
Uses a page.js-style routing string to build up a path you can link to
18 lines (14 loc) • 673 B
JavaScript
// This file to be replaced with an official implementation maintained by
// the page.js crew if and when that becomes an option
var pathToRegexp = require('path-to-regexp-with-reversible-keys')
module.exports = function(pathString) {
var parseResults = pathToRegexp(pathString)
// The only reason I'm returning a new object instead of the results of the pathToRegexp
// function is so that if the official implementation ends up returning an
// allTokens-style array via some other mechanism, I may be able to change this file
// without having to change the rest of the module in index.js
return {
regex: parseResults,
allTokens: parseResults.allTokens
}
}