Skip to content

Commit f137aa3

Browse files
author
Sarfraz Khan
committed
resolving snyk warnign for XSS
1 parent 9a99420 commit f137aa3

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Request/makeRequest.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,22 +223,24 @@ async function makeRequest(
223223
}
224224

225225
if (fileExtension) {
226-
return response.blob().then((blob: any) => {
226+
return response.blob().then((blob: Blob) => {
227227
const url = window.URL.createObjectURL(blob);
228228

229229
const link = document.createElement("a");
230230
link.href = url;
231231
// Now the file name includes the extension
232232
link.setAttribute("download", `file${fileExtension}`);
233233

234-
// These two lines are necessary to make the link click in Firefox
235-
link.style.display = "none";
236-
document.body.appendChild(link);
234+
// These lines are necessary to make the link click in Firefox
235+
const hiddenContainer = document.createElement("div");
236+
hiddenContainer.style.display = "none";
237+
hiddenContainer.appendChild(link);
238+
document.body.appendChild(hiddenContainer);
237239

238240
link.click();
239241

240242
// After link is clicked, it's safe to remove it.
241-
setTimeout(() => document.body.removeChild(link), 0);
243+
setTimeout(() => document.body.removeChild(hiddenContainer), 0);
242244

243245
return response;
244246
});

0 commit comments

Comments
 (0)