Skip to content

Commit

Permalink
refactor: adjust code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed May 30, 2024
1 parent 8bfd7b1 commit 6652187
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ export async function createRouter(
.on('unlink', createTree)
}

const urlRootRE = new RegExp(`^/?${escape(urlRoot)}(?:/|$)`)

function getHandler(file: string, method: string): Promise<Handler | null> {
return handlerCache.use(
`${file}:${method}`,
Expand All @@ -318,8 +320,6 @@ export async function createRouter(
)
}

const urlRootRE = new RegExp(`^/?${escape(urlRoot)}(?:/|$)`)

async function handler(req: Request): Promise<Response> {
if (!methods.has(req.method)) return createStandardResponse(STATUS_CODE.MethodNotAllowed)
if (req.url.length > 8192) return createStandardResponse(STATUS_CODE.URITooLong)
Expand Down

0 comments on commit 6652187

Please sign in to comment.