Skip to content

Commit

Permalink
fix: serialise RegExp
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Feb 2, 2022
1 parent 36a89f5 commit 5546370
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Declaration } from './declaration.js'
import { Handler } from './handler.js'
import { nonNullable } from './utils/non_nullable.js'

const generateManifest = (bundlePath: string, handlers: Handler[], declarations: Declaration[]) => {
const generateManifest = (bundlePath: string, handlers: Handler[], declarations: Declaration[] = []) => {
const handlersWithRoutes = handlers.map((handler) => {
const declaration = declarations.find((candidate) => candidate.handler === handler.name)

Expand All @@ -13,10 +13,11 @@ const generateManifest = (bundlePath: string, handlers: Handler[], declarations:
}

const pattern = 'pattern' in declaration ? new RegExp(declaration.pattern) : globToRegExp(declaration.path)
const serializablePattern = pattern.source.replace(/\\\//g, '/')

return {
handler: handler.name,
pattern: pattern.toString(),
pattern: serializablePattern,
}
})
const manifest = {
Expand Down

0 comments on commit 5546370

Please sign in to comment.