mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Backquote/backtick symbol (`) is not escaped correctly
This commit is contained in:
parent
df9e447aa3
commit
2fcd655b7d
@ -2,8 +2,12 @@ import { escapeDescription } from './escapeDescription';
|
||||
|
||||
describe('escapeDescription', () => {
|
||||
it('should escape', () => {
|
||||
expect(escapeDescription('')).toEqual('');
|
||||
expect(escapeDescription('fooBar')).toEqual('fooBar');
|
||||
expect(escapeDescription('foo `test` bar')).toEqual('foo \\`test\\` bar');
|
||||
});
|
||||
|
||||
it('should not escape', () => {
|
||||
expect(escapeDescription('')).toEqual('');
|
||||
expect(escapeDescription('fooBar')).toEqual('fooBar');
|
||||
expect(escapeDescription('foo \\`test\\` bar')).toEqual('foo \\`test\\` bar');
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
export function escapeDescription(value: string): string {
|
||||
return value.replace(/`/g, '\\`');
|
||||
return value.replace(/([^\\])`/g, '$1\\`');
|
||||
}
|
||||
|
||||
@ -2,8 +2,12 @@ import { escapeDescription } from './escapeDescription';
|
||||
|
||||
describe('escapeDescription', () => {
|
||||
it('should escape', () => {
|
||||
expect(escapeDescription('')).toEqual('');
|
||||
expect(escapeDescription('fooBar')).toEqual('fooBar');
|
||||
expect(escapeDescription('foo `test` bar')).toEqual('foo \\`test\\` bar');
|
||||
});
|
||||
|
||||
it('should not escape', () => {
|
||||
expect(escapeDescription('')).toEqual('');
|
||||
expect(escapeDescription('fooBar')).toEqual('fooBar');
|
||||
expect(escapeDescription('foo \\`test\\` bar')).toEqual('foo \\`test\\` bar');
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
export function escapeDescription(value: string): string {
|
||||
return value.replace(/`/g, '\\`');
|
||||
return value.replace(/([^\\])`/g, '$1\\`');
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user