Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

change regex pattern for dynamic routes to accept hyphens / underscores #17

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const DYNAMIC_PATH_REGEX = '[a-zA-Z]+'
const DYNAMIC_PATH_REGEX = '[0-9A-Za-z._-]+'

export const getContent = (options, path, target, pathVariables) => {
let { Component, props } = options[path]
Expand Down Expand Up @@ -37,7 +37,7 @@ export const getPathVariables = (sections, matches) => {
export const getPathRegex = sections => {
return sections.map((value) => {
if (value.match(new RegExp(`:${DYNAMIC_PATH_REGEX}`)) !== null) {
return `([a-zA-Z0-9]+)`
return `([0-9A-Za-z._-]+)`
}
return value
}).join('\\/')
Expand Down