Skip to content

Commit 14027ed

Browse files
committed
Fix regexp
1 parent 70d23c0 commit 14027ed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/middlewares/json-api-koa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ async function authenticate(app: Application, ctx: Context) {
7373

7474
function urlData(app: Application, ctx: Context) {
7575
const urlRegexp = new RegExp(
76-
`^\/?(?<namespace>${escapeStringRegexp(
76+
`^(\/+)?((?<namespace>${escapeStringRegexp(
7777
app.namespace
78-
)})(\/?(?<resource>[^\/]+))?(\/(?<id>\\S+))?`
78+
)})(\/+|$))?(?<resource>[^\s\/?]+)?(\/+)?(?<id>[^\s\/?]+)?(\/+)?`
7979
);
8080

8181
return (ctx.path.match(urlRegexp) || {})["groups"] || {};

0 commit comments

Comments
 (0)