fix: trimStart to text

This commit is contained in:
Sidharth Vinod 2023-03-31 00:25:33 +05:30
parent d16894daf4
commit 1945a62990
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
2 changed files with 12 additions and 12 deletions

View File

@ -14,13 +14,13 @@ graph TD
%% This is a comment %% This is a comment
`; `;
expect(cleanupComments(text)).toMatchInlineSnapshot(` expect(cleanupComments(text)).toMatchInlineSnapshot(`
" "
graph TD graph TD
A-->B A-->B
" "
`); `);
}); });
it('should keep init statements when removing comments', () => { it('should keep init statements when removing comments', () => {
@ -61,12 +61,12 @@ graph TD
C-->D C-->D
`; `;
expect(cleanupComments(text)).toMatchInlineSnapshot(` expect(cleanupComments(text)).toMatchInlineSnapshot(`
" "
graph TD graph TD
A-->B A-->B
C-->D C-->D
" "
`); `);
}); });
}); });

View File

@ -4,5 +4,5 @@
* @returns cleaned text * @returns cleaned text
*/ */
export const cleanupComments = (text: string): string => { export const cleanupComments = (text: string): string => {
return text.replace(/^\s*%%(?!{)[^\n]+/gm, ''); return text.trimStart().replace(/^\s*%%(?!{)[^\n]+/gm, '');
}; };