Support running in subdirectory with base_path config

This commit is contained in:
Toby Zerner
2015-08-13 12:58:59 +09:30
parent aec83b295a
commit 9c7fab5d8c
5 changed files with 13 additions and 5 deletions

View File

@ -4,9 +4,10 @@
*
* @see https://lhorie.github.io/mithril/mithril.route.html#defining-routes
* @param {Object} routes
* @param {String} [basePath]
* @return {Object}
*/
export default function mapRoutes(routes) {
export default function mapRoutes(routes, basePath = '') {
const map = {};
for (const key in routes) {
@ -14,7 +15,7 @@ export default function mapRoutes(routes) {
if (route.component) route.component.props.routeName = key;
map[route.path] = route.component;
map[basePath + route.path] = route.component;
}
return map;