Skip to content

Commit

Permalink
fix: escaped single letter ids generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael M committed Oct 27, 2023
1 parent d48c23a commit aa1fe18
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/ng-openapi-gen/src/lib/utils/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export function refName(fullRef: string): string {

/** Escapes the name of a property / parameter if not valid JS identifier */
export function escapeId(name: string) {
// eslint-disable-next-line unicorn/better-regex
return /^[a-zA-Z]\w+$/.test(name) ? name : `'${name.replace(/'/g, "\\'")}'`;
return /^[A-Za-z]\w*$/.test(name) ? name : `'${name.replace(/'/g, "\\'")}'`;

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
}

/** Returns the TypeScript comments for the given schema description, in a given indentation level */
Expand Down

0 comments on commit aa1fe18

Please sign in to comment.