Skip to content

Commit

Permalink
feat($core): support prefix $ to dynamic routing
Browse files Browse the repository at this point in the history
Deprecated prefix `_`
  • Loading branch information
2nthony committed Jun 22, 2019
1 parent b5ec485 commit 20f27c0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/collect-fs-routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-await-in-loop */

// Modified from @ream/collect-fs-routes
// author: @egoist
// https://github.com/ream/collect-fs-routes

const fs = require('fs')
Expand Down Expand Up @@ -49,12 +50,13 @@ const filePath2RoutePath = path =>
path
.replace('index', '')
.replace(/_/g, ':')
.replace(/\$/g, ':')
.replace(/\{(.*?)\}/g, ':$1')

const chunkNamify = (str, prefix) =>
path
.relative(prefix, str)
.replace(/[^a-zA-Z0-9\-_{}]/g, '-')
.replace(/[^a-zA-Z0-9\-_{}$]/g, '-')
.replace(/^-+/, '')

function renderRoutes(
Expand Down

0 comments on commit 20f27c0

Please sign in to comment.