Fix Code Scanning Alert #1292 (#202125)

## Summary

Resolves [#1292](https://github.com/elastic/kibana-team/issues/1292)


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
This commit is contained in:
Alejandro Fernández Haro 2024-11-29 13:35:49 +01:00 committed by GitHub
parent 02e9ee48c3
commit 841d052776
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -117,10 +117,12 @@ describe('assignToPaths', () => {
assignToPaths(paths, '/foo', {});
assignToPaths(paths, '/bar/{id?}', {});
assignToPaths(paths, '/bar/file/{path*}', {});
assignToPaths(paths, '/bar/file/{path*}/{id?}', {});
expect(paths).toEqual({
'/foo': {},
'/bar/{id}': {},
'/bar/file/{path}': {},
'/bar/file/{path}/{id}': {},
});
});
});

View file

@ -132,7 +132,7 @@ export const assignToPaths = (
path: string,
pathObject: OpenAPIV3.PathItemObject
): void => {
const pathName = path.replace(/[\?\*]/, '');
const pathName = path.replace(/[\?\*]/g, '');
paths[pathName] = { ...paths[pathName], ...pathObject };
};