Skip to content

Commit

Permalink
Merge pull request #65 from Mozilla-Ocho/bug/pdf-page-name
Browse files Browse the repository at this point in the history
Fix the generated filename for pdfs
  • Loading branch information
johnshaughnessy authored Mar 7, 2024
2 parents 775105c + 6644032 commit 4ee8e93
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions extension/popup/memory_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ async function generateFileName(ext) {
}
})
.then ((fileName)=> {
return fileName.replaceAll(":","");
return fileName.replaceAll(":","")
.replaceAll("!","")
.replaceAll("?","")
.replaceAll("/","")
.replaceAll("\\","")
.replaceAll("*","")
.replaceAll("|","")
.replaceAll(" ","")
.replaceAll("<","")
.replaceAll(">","");
})
.catch((error) => {
reject(`Error querying tabs: ${error}`);
Expand All @@ -34,7 +43,7 @@ async function savePDF() {
// Fallback to non-silent mode.
await browser.tabs.saveAsPDF({
// Omit the DOWNLOAD_SUBDIRECTORY prefix because saveAsPDF will not respect it.
toFileName: `PAGE-${generateFileName("pdf")}`,
toFileName: `PAGE-${await generateFileName("pdf")}`,
});
}
}
Expand Down

0 comments on commit 4ee8e93

Please sign in to comment.