Skip to content

Commit

Permalink
Merge pull request #7141 from QwikDev/v2-fix-code-ql
Browse files Browse the repository at this point in the history
fix: api docs generation regexp
  • Loading branch information
shairez authored Dec 13, 2024
2 parents 1def076 + bedf0c3 commit 3eb4f34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/docs/src/routes/api/qwik/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2214,4 +2214,4 @@
"mdFile": "core.withlocale.md"
}
]
}
}
12 changes: 10 additions & 2 deletions scripts/api-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ async function createApiMarkdown(a: ApiData) {
md.push(``);

// sanitize / adjust output
const content = m.content
.replace(/<!--(.|\s)*?-->/g, '')
const content = removeHtmlComments(m.content)
// .replace(/<Slot\/>/g, ''
.replace(/\\#\\#\\# (\w+)/gm, '### $1')
.replace(/\\\[/gm, '[')
Expand All @@ -232,6 +231,15 @@ async function createApiMarkdown(a: ApiData) {
return mdOutput;
}

function removeHtmlComments(input: string): string {
let previous;
do {
previous = input;
input = input.replace(/<!--(\s*|.*)--!?>/g, '');

Check failure

Code scanning / CodeQL

Bad HTML filtering regexp High

This regular expression does not match comments containing newlines.
} while (input !== previous);
return input;
}

interface ApiData {
id: string;
package: string;
Expand Down

0 comments on commit 3eb4f34

Please sign in to comment.