Skip to content

Commit

Permalink
Fix load error messages on "data:" URL and "http:" on "https:" context
Browse files Browse the repository at this point in the history
  • Loading branch information
MurakamiShinyu committed Feb 24, 2019
1 parent 6b1f7cd commit c2df75f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/adapt/epub.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,13 @@ adapt.epub.EPUBDocStore.prototype.load = function(url) {
r = adapt.epub.EPUBDocStore.superClass_.load.call(this, docURL, true, `Failed to fetch a source document from ${docURL}`);
r.then(xmldoc => {
if (!xmldoc) {
vivliostyle.logging.logger.error(`Received an empty response for ${docURL}. This may be caused by the server not allowing cross-origin resource sharing (CORS).`);
if (docURL.startsWith("data:")) {
vivliostyle.logging.logger.error(`Failed to load ${docURL}. Invalid data.`);
} else if (docURL.startsWith("http:") && adapt.base.baseURL.startsWith("https:")) {
vivliostyle.logging.logger.error(`Failed to load ${docURL}. Mixed Content ("http:" content on "https:" context) is not allowed.`);
} else {
vivliostyle.logging.logger.error(`Received an empty response for ${docURL}. This may be caused by the server not allowing cross-origin resource sharing (CORS).`);
}
} else {
frame.finish(xmldoc);
}
Expand Down

0 comments on commit c2df75f

Please sign in to comment.