Skip to content

Commit

Permalink
fix(middleware): strip leading and trailing underlines from HttpError…
Browse files Browse the repository at this point in the history
… codes
  • Loading branch information
DASPRiD committed Mar 7, 2024
1 parent a67f26a commit 8e6b734
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const jsonApiErrorMiddleware = (options?: ErrorMiddlewareOptions): Middle
status: error.status.toString(),
code: error.name
.replace(/Error$/, "")
.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`),
.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)
.replace(/^_+|_+$/g, ""),
title: error.message,
});

Expand Down

0 comments on commit 8e6b734

Please sign in to comment.