File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { OpenAPI2 , OpenAPI3 , ReferenceObject } from "./types" ;
2
2
3
3
export function comment ( text : string ) : string {
4
- const commentText = text . trim ( ) ;
4
+ const commentText = text . trim ( ) . replace ( / \* \/ / g , "*\\/" ) ;
5
5
6
6
// if single-line comment
7
7
if ( commentText . indexOf ( "\n" ) === - 1 ) {
Original file line number Diff line number Diff line change 1
- import { swaggerVersion } from "../../src/utils" ;
1
+ import { swaggerVersion , comment } from "../../src/utils" ;
2
2
3
3
describe ( "swaggerVersion" , ( ) => {
4
4
it ( "v2" , ( ) => {
@@ -11,3 +11,18 @@ describe("swaggerVersion", () => {
11
11
expect ( ( ) => swaggerVersion ( { } as any ) ) . toThrow ( ) ;
12
12
} ) ;
13
13
} ) ;
14
+
15
+ describe ( "comment" , ( ) => {
16
+ it ( "escapes markdown in comments" , ( ) => {
17
+ const text = `Example markdown
18
+ **/some/url/path**` ;
19
+
20
+ expect ( comment ( text ) ) . toBe (
21
+ `/**
22
+ * Example markdown
23
+ * **\\/some/url/path**
24
+ */
25
+ `
26
+ ) ;
27
+ } ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments