Skip to content

Commit 62f8d76

Browse files
committed
refactor: simplify regexp with a captured group
1 parent 721f09c commit 62f8d76

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/cli.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ const removePlaceholders = (query) => query.replace(/(?<=:)[pb]\./g, '');
5050

5151
// "/categories/:id" => "/categories/{id}"
5252
// (used only with Golang's go-chi)
53-
const convertPathPlaceholders = (path) => {
54-
return path.replace(/:[^\/]+/g, (placeholder) => '{' + placeholder.slice(1) + '}');
55-
};
53+
const convertPathPlaceholders = (path) => path.replace(/:([^\/]+)/g, '{$1}');
5654

5755
const createEndpoints = async (destDir, lang, config) => {
5856
const fileName = `routes.${lang}`

0 commit comments

Comments
 (0)