Skip to content

Commit

Permalink
Improve PDF detection
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Aug 14, 2020
1 parent bb8243a commit e7e09fe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/core/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ const launchPdfViewer = (settings) => {
};

const onPdfDocument = (url, pdfUrlPattern) => {
const e = document.body?.children?.[0];
if (e?.tagName === "EMBED" && e?.type === "application/pdf") {
return true;
}

if (!pdfUrlPattern) {
return false;
}

try {
const re = new RegExp(pdfUrlPattern);
return re.test(url);
Expand Down

0 comments on commit e7e09fe

Please sign in to comment.