webodf / ViewerJS

ViewerJS: Document Reader in JavaScript
http://viewerjs.org
1.94k stars 421 forks source link

content type checks to strict #183

Open SnakeSVx opened 8 years ago

SnakeSVx commented 8 years ago

Hello,

While using viewerjs and upgrading some libraries on the serverside we noticed that all of a sudden viewerjs wasn't able to detect anymore that we were trying to display a PDF document.

We traced this problem to be be caused by the supportsMimetype being to strict in it's checking. Our server application was returning the following content type header: Content-Type:application/pdf;charset=UTF-8, while the supportsMimetype method is using an equals check.

As a patch in our own code we changed this method to do a partial check.

Original code: supportsMimetype:function(a){return"application/pdf"===a}

Modified code: supportsMimetype:function(a){return a.slice(0, 15) === "application/pdf"}

Would it be possible to fix this in the official version as well?

Thanks in advance.

maxlinux2000 commented 8 years ago

any news how to fix it? under chromium/chrome under ubuntu and android, and crosswalk-webview (in my cordova app) it works just fine. But under Firefox (ubuntu and android) viewerjs cant' display the pdf, and instead it show me: "A plugin is needed to display this content"

Any way to fix it via server side?