Skip to content

Commit

Permalink
Merge pull request #1687 from hunshcn/fix/plus
Browse files Browse the repository at this point in the history
fix: sanitize "+" in uri
  • Loading branch information
mrlubos authored Feb 10, 2025
2 parents 1df55ed + e8b3058 commit 1de7641
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-parents-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': patch
---

sanitize "+" in uri to avoid plus in function name
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('sanitizeNamespaceIdentifier', () => {
{ expected: 'æbc', input: 'æbc' },
{ expected: 'æb-c', input: 'æb.c' },
{ expected: 'æb-c', input: '1æb.c' },
{ expected: 'a-b-c--d--e', input: 'a/b{c}/d/$e' },
{ expected: 'a-b-c--d---e', input: 'a/b{c}/d/$+e' },
])(
'sanitizeNamespaceIdentifier($input) -> $expected',
({ expected, input }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/openApi/common/parser/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const sanitizeNamespaceIdentifier = (name: string) =>
name
.replace(/^[^\p{ID_Start}]+/u, '')
.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu, '-')
.replace(/\$/g, '-');
.replace(/[$+]/g, '-');

export const sanitizeOperationParameterName = (name: string) => {
const withoutBrackets = name.replace('[]', 'Array');
Expand Down

0 comments on commit 1de7641

Please sign in to comment.