Skip to content

Commit

Permalink
Merge pull request #477 from kiwix/fix-epub-and-other-mime-types-in-S…
Browse files Browse the repository at this point in the history
…W-mode

Add MIME-type in the SW response, for epub and other file extensions.
  • Loading branch information
mossroy authored Mar 2, 2019
2 parents 088b7b9 + 09ae8e2 commit d1d5d24
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ var regexpWEBM = new RegExp(/\.webm$/i);
var regexpMP4 = new RegExp(/\.mp4$/i);
var regexpOGG = new RegExp(/\.og[mvg]$/i);
var regexpVTT = new RegExp(/\.vtt$/i);
var regexpPDF = new RegExp(/\.pdf$/i);
var regexpZIP = new RegExp(/\.zip$/i);
var regexpEPUB = new RegExp(/\.epub$/i);

// Pattern for ZIM file namespace - see https://wiki.openzim.org/wiki/ZIM_file_format#Namespaces
var regexpZIMUrlWithNamespace = new RegExp(/(?:^|\/)([-ABIJMUVWX])\/(.+)/);
Expand Down Expand Up @@ -130,6 +133,15 @@ function fetchEventListener(event) {
else if (regexpOGG.test(title)) {
contentType = 'video/ogg';
}
else if (regexpPDF.test(title)) {
contentType = 'application/pdf';
}
else if (regexpEPUB.test(title)) {
contentType = 'application/epub+zip';
}
else if (regexpZIP.test(title)) {
contentType = 'application/zip';
}
}
else if (nameSpace === '-') {
// It's a layout dependency
Expand Down

0 comments on commit d1d5d24

Please sign in to comment.