Skip to content

Commit

Permalink
Use the repeat key value to determine if the argument is a file or a
Browse files Browse the repository at this point in the history
key. Fixes #111.
  • Loading branch information
ivmartel committed Sep 23, 2014
1 parent 4e949d1 commit f0f286d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/gui/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ dwv.html.decodeKeyValueUri = function(uri, replaceMode)
var repeatList = inputQueryPairs.query[repeatKey];
// build base uri
var baseUrl = inputQueryPairs.base;
// do not add '?' for what looks like file elements
// root/path/to/?key=0.jpg&key=1.jpg
if( !( baseUrl[baseUrl.length-1] === '/' && repeatList[0].indexOf('.') !== -1 ) ) {
// do not add '?' when the repeatKey is 'file'
// root/path/to/?file=0.jpg&file=1.jpg
if( repeatKey !== "file" ) {
baseUrl += "?";
}
var gotOneArg = false;
Expand Down
10 changes: 5 additions & 5 deletions tests/html/html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,31 +108,31 @@ test("Test get URI param.", function() {
var full20 = root20 + encodeURIComponent(uri20);
var res20 = dwv.html.getUriParam(full20);
var theo20 = ["result?a=0"];
equal(res20.toString(), theo20.toString(), "Multiple File uri with one arg");
equal(res20.toString(), theo20.toString(), "Multiple key uri with one arg");

// simple test: two arguments
var root21 = "file:///test.html?input=";
var uri21 = "result?a=0&a=1";
var full21 = root21 + encodeURIComponent(uri21);
var res21 = dwv.html.getUriParam(full21);
var theo21 = ["result?a=0", "result?a=1"];
equal(res21.toString(), theo21.toString(), "Multiple File uri with two args");
equal(res21.toString(), theo21.toString(), "Multiple key uri with two args");

// simple test: three arguments
var root22 = "file:///test.html?input=";
var uri22 = "result?a=0&a=1&a=2";
var full22 = root22 + encodeURIComponent(uri22);
var res22 = dwv.html.getUriParam(full22);
var theo22 = ["result?a=0", "result?a=1", "result?a=2"];
equal(res22.toString(), theo22.toString(), "Multiple File uri with three args");
equal(res22.toString(), theo22.toString(), "Multiple key uri with three args");

// simple test: plenty arguments
var root23 = "file:///test.html?input=";
var uri23 = "result?a=0&a=1&a=2&b=3&c=4";
var full23 = root23 + encodeURIComponent(uri23);
var res23 = dwv.html.getUriParam(full23);
var theo23 = ["result?b=3&c=4&a=0", "result?b=3&c=4&a=1", "result?b=3&c=4&a=2"];
equal(res23.toString(), theo23.toString(), "Multiple File uri with plenty args");
equal(res23.toString(), theo23.toString(), "Multiple key uri with plenty args");

// real world multiple URI

Expand All @@ -159,7 +159,7 @@ test("Test get URI param.", function() {

// simple test: plenty arguments
var root40 = "file:///test.html?input=";
var uri40 = "web/path/to/file/?a=0.dcm&a=1.dcm&a=2.dcm";
var uri40 = "web/path/to/file/?file=0.dcm&file=1.dcm&file=2.dcm";
var full40 = root40 + encodeURIComponent(uri40) + "&dwvReplaceMode=void";
var res40 = dwv.html.getUriParam(full40);
var theo40 = ["web/path/to/file/0.dcm", "web/path/to/file/1.dcm", "web/path/to/file/2.dcm"];
Expand Down

0 comments on commit f0f286d

Please sign in to comment.