Skip to content

Commit

Permalink
Add an extension check on urls. Fixes #125.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Feb 23, 2015
1 parent 73cb7b1 commit 9630e4e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/io/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,21 @@ dwv.io.Url.prototype.load = function(ioArray)
// Request handler
var onLoadRequest = function(/*event*/)
{
// find the image type
// find the image type from its signature
var view = new DataView(this.response);
var isJpeg = view.getUint32(0) === 0xffd8ffe0;
var isPng = view.getUint32(0) === 0x89504e47;
var isGif = view.getUint32(0) === 0x47494638;

// check possible extension
if( !isJpeg && !isPng && !isGif )
{
var ext = this.responseURL.split('.').pop().toLowerCase();
isJpeg = (ext === "jpg") || (ext === "jpeg");
isPng = (ext === "png");
isGif = (ext === "gif");
}

// non DICOM
if( isJpeg || isPng || isGif )
{
Expand Down

0 comments on commit 9630e4e

Please sign in to comment.