Skip to content

Commit

Permalink
Do not rely on remote hosts preserving query string
Browse files Browse the repository at this point in the history
  • Loading branch information
eweitz committed Apr 16, 2018
1 parent 5822260 commit a8237c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/js/ideogram.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/ideogram.min.js.map

Large diffs are not rendered by default.

25 changes: 19 additions & 6 deletions src/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,17 +428,30 @@ function init() {
) {

var bandDataUrl = ideo.config.dataDir + bandDataFileNames[taxid];
// Ensures correct taxid is processed in response callback; using
// simply 'taxid' variable gives the last *requested* taxid, which
// fails when dealing with multiple taxa.
bandDataUrl += '?taxid=' + taxid;

fetch(bandDataUrl)
.then(function(response) {
return response.text().then(function(text) {

// Fetched data is a JavaScript variable, so assign it
eval(text);
var taxid = response.url.split('taxid=')[1];
ideo.bandData[taxid] = chrBands;

// Ensures correct taxid is processed
// in response callback; using simply upstream 'taxid' variable
// gives the last *requested* taxid, which fails when dealing
// with multiple taxa.
var fetchedTaxid, tid, bandDataFileName;
for (tid in bandDataFileNames) {
bandDataFileName = bandDataFileNames[tid];
if (
response.url.includes(bandDataFileName) &&
bandDataFileName !== ''
) {
fetchedTaxid = tid;
}
}

ideo.bandData[fetchedTaxid] = chrBands;
numBandDataResponses += 1;

if (numBandDataResponses === taxids.length) {
Expand Down

0 comments on commit a8237c2

Please sign in to comment.