File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 11import { OpenAPI2 , OpenAPI3 , ReferenceObject } from "./types" ;
22
33export function comment ( text : string ) : string {
4- const commentText = text . trim ( ) ;
4+ const commentText = text . trim ( ) . replace ( / \* \/ / g , "*\\/" ) ;
55
66 // if single-line comment
77 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" ;
22
33describe ( "swaggerVersion" , ( ) => {
44 it ( "v2" , ( ) => {
@@ -11,3 +11,18 @@ describe("swaggerVersion", () => {
1111 expect ( ( ) => swaggerVersion ( { } as any ) ) . toThrow ( ) ;
1212 } ) ;
1313} ) ;
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