Skip to content

Commit 116cbe1

Browse files
committed
fix: path part name pattern
- Fixes the bug that `addResource` extracted an incorrect parameter name from the path when two or more parameters are included in the path is fixed. The incorrect regex pattern contained slashes in a parameter name. Now the regex pattern is fixed to exclude slashes. issue #8
1 parent 2876ae4 commit 116cbe1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/rest-api-with-spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ function translatePathPart(
337337
resource: IResourceWithSpec,
338338
): ParameterObject[] | undefined {
339339
// locates /{name} at the end
340-
const match = resource.path.match(/\/\{(.+)\}$/);
340+
// `name` must not contain a slash: https://github.com/codemonger-io/cdk-rest-api-with-spec/issues/8
341+
const match = resource.path.match(/\/\{([^\/]+)\}$/);
341342
if (match == null) {
342343
return undefined;
343344
}

0 commit comments

Comments
 (0)