always create valid route id

This commit is contained in:
Rich Harris
2017-12-13 12:23:49 -05:00
parent db4223133e
commit a8373c1568

View File

@@ -8,7 +8,7 @@ module.exports = function create_matchers(files) {
const parts = file.replace(/\.(html|js|mjs)$/, '').split(path.sep);
if (parts[parts.length - 1] === 'index') parts.pop();
const id = parts.join('_').replace(/[[\]]/g, '$');
const id = parts.join('_').replace(/[[\]]/g, '$') || '_';
const dynamic = parts
.filter(part => part[0] === '[')