Skip to content

Commit

Permalink
Fix GIF header detection for some servers
Browse files Browse the repository at this point in the history
Servers might not respond to the Range HTTP header.
For example: https://developer.android.com/studio/preview/features/images/jni-autocomplete.gif
  • Loading branch information
geekley committed Feb 29, 2020
1 parent bd22e1b commit 112f7fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions js/scrubber.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ window.addEventListener('load', () => {
const h = new XMLHttpRequest();
h.open('GET', url);
h.setRequestHeader('Range', 'bytes=0-5');
h.onload = request => {
h.onload = () => {
const validHeaders = ['GIF87a', 'GIF89a'];
if (validHeaders.includes(request.target.response)) use(url);
if (validHeaders.includes(h.responseText.substr(0, 6))) use(url);
else ignore('bad header');
}
};
h.onerror = () => ignore('error loading');
h.send(null);
});
Expand Down

0 comments on commit 112f7fd

Please sign in to comment.