From 39a1eb82fa5017579d0b7f2bc5c615f6649fdd3f Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Thu, 12 Mar 2020 19:31:04 +0100 Subject: [PATCH] Support for viewing .nii.gz --- frontend/src/js/component/wb-collection-content.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/js/component/wb-collection-content.js b/frontend/src/js/component/wb-collection-content.js index 7c0d301..66f6042 100644 --- a/frontend/src/js/component/wb-collection-content.js +++ b/frontend/src/js/component/wb-collection-content.js @@ -15,6 +15,14 @@ function encodeURIComponentIncludingDots(s) { return encodeURIComponent(s).replace('.', '%2E'); } +function endsWith(what, endings) { + if (typeof(endings) === 'string') + return what.endsWith(endings); + if (endings instanceof Array) + return endings.map(a => what.endsWith(a)).reduce((a, b) => (a || b)); + throw Error('Expected second argument to be either a string or an array'); +} + class WBCollectionContent extends Component { constructor(...args) { super(...args); @@ -143,7 +151,7 @@ class WBCollectionContent extends Component { alert('Not implemented.') } }> - { item[1].toLowerCase().endsWith('.nii') ? ( + { endsWith(item[1].toLowerCase(), ['.nii', '.nii.gz']) ? ( + }) }> ) : null } ) : null)