Skip to content

Commit 13bf29c

Browse files
committed
1 parent fb7caae commit 13bf29c

File tree

8 files changed

+8
-4
lines changed

8 files changed

+8
-4
lines changed

src/openApi/v2/parser/escapeDescription.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ describe('escapeDescription', () => {
99
expect(escapeDescription('')).toEqual('');
1010
expect(escapeDescription('fooBar')).toEqual('fooBar');
1111
expect(escapeDescription('foo \\`test\\` bar')).toEqual('foo \\`test\\` bar');
12+
expect(escapeDescription('foo */bar/*')).toEqual('foo *_/bar/*');
1213
});
1314
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export function escapeDescription(value: string): string {
2-
return value.replace(/([^\\])`/g, '$1\\`');
2+
return value.replace(/([^\\])`/g, '$1\\`').replace(/(\*\/)/g, '*_/');
33
}

src/openApi/v2/parser/getComment.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('getComment', () => {
88
expect(getComment('')).toEqual(null);
99
expect(getComment('Hello')).toEqual('Hello');
1010
expect(getComment('Hello World!')).toEqual('Hello World!');
11+
expect(getComment('Testing */escape/*')).toEqual('Testing *_/escape/*');
1112
expect(getComment('Testing multiline comments.\nThis must go to the next line.\n\nThis will contain a break.')).toEqual(multiline);
1213
expect(getComment('Testing multiline comments.\r\nThis must go to the next line.\r\n\r\nThis will contain a break.')).toEqual(multiline);
1314
});

src/openApi/v2/parser/getComment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { EOL } from 'os';
77
*/
88
export function getComment(comment?: string): string | null {
99
if (comment) {
10-
return comment.replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`);
10+
return comment.replace(/(\*\/)/g, '*_/').replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`);
1111
}
1212
return null;
1313
}

src/openApi/v3/parser/escapeDescription.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ describe('escapeDescription', () => {
99
expect(escapeDescription('')).toEqual('');
1010
expect(escapeDescription('fooBar')).toEqual('fooBar');
1111
expect(escapeDescription('foo \\`test\\` bar')).toEqual('foo \\`test\\` bar');
12+
expect(escapeDescription('foo */bar/*')).toEqual('foo *_/bar/*');
1213
});
1314
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export function escapeDescription(value: string): string {
2-
return value.replace(/([^\\])`/g, '$1\\`');
2+
return value.replace(/([^\\])`/g, '$1\\`').replace(/(\*\/)/g, '*_/');
33
}

src/openApi/v3/parser/getComment.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('getComment', () => {
88
expect(getComment('')).toEqual(null);
99
expect(getComment('Hello')).toEqual('Hello');
1010
expect(getComment('Hello World!')).toEqual('Hello World!');
11+
expect(getComment('Testing */escape/*')).toEqual('Testing *_/escape/*');
1112
expect(getComment('Testing multiline comments.\nThis must go to the next line.\n\nThis will contain a break.')).toEqual(multiline);
1213
expect(getComment('Testing multiline comments.\r\nThis must go to the next line.\r\n\r\nThis will contain a break.')).toEqual(multiline);
1314
});

src/openApi/v3/parser/getComment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { EOL } from 'os';
77
*/
88
export function getComment(comment?: string): string | null {
99
if (comment) {
10-
return comment.replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`);
10+
return comment.replace(/(\*\/)/g, '*_/').replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`);
1111
}
1212
return null;
1313
}

0 commit comments

Comments
 (0)