Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly use http or https as per the current browsing environment #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions translate/liblouis-worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// The origin of the URL where we are hosted. Most likely `http://liblouis.io` or `https://liblouis.io`.
const ORIGIN = self.location.origin;

self.onmessage = (function() {
CMD = {
importLib: function(data) {
importScripts("http://liblouis.io/js-build/build-no-tables-utf32.js");
importScripts(ORIGIN + "/js-build/build-no-tables-utf32.js");
importScripts("liblouis-easy-api.js");
liblouis.setLogLevel(liblouis.LOG.INFO);
liblouis.registerLogCallback(function(lvl, msg) {
Expand Down Expand Up @@ -44,7 +47,7 @@ self.onmessage = (function() {
continue; // ignore parse error
}
tableIndexName = line.substring(0, len);
tableUrl = new URL(tablePath, "http://liblouis.io/js-build/tables/_/_").href;
tableUrl = new URL(tablePath, ORIGIN + "/js-build/tables/_/_").href;
tableFileName = tableUrl.substring(tableUrl.lastIndexOf('/') + 1);
capi.FS.createLazyFile(tableFolder, tableFileName, tableUrl, true, true);
tables.push(tableFolder + "/" + tableFileName);
Expand All @@ -54,7 +57,7 @@ self.onmessage = (function() {
}
}
// this needs to come after the createLazyFile stuff because of how bindDynLoader works
liblouis.enableOnDemandTableLoading("http://liblouis.io/js-build/tables/");
liblouis.enableOnDemandTableLoading(ORIGIN + "/js-build/tables/");
// This takes too long, getting info from index file instead
/*ptr = capi.ccall("lou_listTables", "number", [], []);
if (ptr) {
Expand Down