dwv 0.31.3 → 0.31.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dwv.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! dwv 0.31.3 2023-11-16 12:13:08 */
1
+ /*! dwv 0.31.4 2024-02-20 12:23:37 */
2
2
  // Inspired from umdjs
3
3
  // See https://github.com/umdjs/umd/blob/master/templates/returnExports.js
4
4
  (function (root, factory) {
@@ -4759,7 +4759,7 @@ dwv.dicom = dwv.dicom || {};
4759
4759
  * @returns {string} The version of the library.
4760
4760
  */
4761
4761
  dwv.getVersion = function () {
4762
- return '0.31.3';
4762
+ return '0.31.4';
4763
4763
  };
4764
4764
 
4765
4765
  /**
@@ -24130,16 +24130,18 @@ dwv.io.DicomDataLoader.prototype.canLoadFile = function (file) {
24130
24130
  * @returns {boolean} True if the url can be loaded.
24131
24131
  */
24132
24132
  dwv.io.DicomDataLoader.prototype.canLoadUrl = function (url, options) {
24133
- // if there are options.requestHeaders, just base check on them
24133
+ // check options.requestHeaders for 'Accept'
24134
24134
  if (typeof options !== 'undefined' &&
24135
24135
  typeof options.requestHeaders !== 'undefined') {
24136
- // starts with 'application/dicom'
24137
- var isDicom = function (element) {
24138
- return element.name === 'Accept' &&
24139
- dwv.utils.startsWith(element.value, 'application/dicom') &&
24140
- element.value[18] !== '+';
24136
+ var isNameAccept = function (element) {
24137
+ return element.name === 'Accept';
24141
24138
  };
24142
- return typeof options.requestHeaders.find(isDicom) !== 'undefined';
24139
+ var acceptHeader = options.requestHeaders.find(isNameAccept);
24140
+ if (typeof acceptHeader !== 'undefined') {
24141
+ // starts with 'application/dicom' and no '+'
24142
+ return dwv.utils.startsWith(acceptHeader.value, 'application/dicom') &&
24143
+ acceptHeader.value[18] !== '+';
24144
+ }
24143
24145
  }
24144
24146
 
24145
24147
  var urlObjext = dwv.utils.getUrlFromUri(url);
@@ -24752,16 +24754,18 @@ dwv.io.JSONTextLoader.prototype.canLoadFile = function (file) {
24752
24754
  * @returns {boolean} True if the url can be loaded.
24753
24755
  */
24754
24756
  dwv.io.JSONTextLoader.prototype.canLoadUrl = function (url, options) {
24755
- // if there are options.requestHeader, just base check on them
24757
+ // check options.requestHeaders for 'Accept'
24756
24758
  if (typeof options !== 'undefined' &&
24757
24759
  typeof options.requestHeaders !== 'undefined') {
24758
- // starts with 'application/json' or 'application/dicom+json
24759
- var isJson = function (element) {
24760
- return element.name === 'Accept' &&
24761
- dwv.utils.startsWith(element.value, 'application/json') &&
24762
- dwv.utils.startsWith(element.value, 'application/dicom+json');
24760
+ var isNameAccept = function (element) {
24761
+ return element.name === 'Accept';
24763
24762
  };
24764
- return typeof options.requestHeaders.find(isJson) !== 'undefined';
24763
+ var acceptHeader = options.requestHeaders.find(isNameAccept);
24764
+ if (typeof acceptHeader !== 'undefined') {
24765
+ // starts with 'application/json' or 'application/dicom+json
24766
+ return dwv.utils.startsWith(acceptHeader.value, 'application/json') ||
24767
+ dwv.utils.startsWith(acceptHeader.value, 'application/dicom+json');
24768
+ }
24765
24769
  }
24766
24770
 
24767
24771
  var urlObjext = dwv.utils.getUrlFromUri(url);
@@ -25266,14 +25270,17 @@ dwv.io.MultipartLoader.prototype.canLoadFile = function (_file) {
25266
25270
  * @returns {boolean} True if the url can be loaded.
25267
25271
  */
25268
25272
  dwv.io.MultipartLoader.prototype.canLoadUrl = function (url, options) {
25269
- // if there are options.requestHeaders, just base check on them
25273
+ // check options.requestHeaders for 'Accept'
25270
25274
  if (typeof options !== 'undefined' &&
25271
25275
  typeof options.requestHeaders !== 'undefined') {
25272
- var isMultipart = function (element) {
25273
- return element.name === 'Accept' &&
25274
- dwv.utils.startsWith(element.value, 'multipart/related');
25276
+ var isNameAccept = function (element) {
25277
+ return element.name === 'Accept';
25275
25278
  };
25276
- return typeof options.requestHeaders.find(isMultipart) !== 'undefined';
25279
+ var acceptHeader = options.requestHeaders.find(isNameAccept);
25280
+ if (typeof acceptHeader !== 'undefined') {
25281
+ // starts with 'multipart/related'
25282
+ return dwv.utils.startsWith(acceptHeader.value, 'multipart/related');
25283
+ }
25277
25284
  }
25278
25285
 
25279
25286
  return false;
@@ -25500,15 +25507,17 @@ dwv.io.RawImageLoader.prototype.canLoadFile = function (file) {
25500
25507
  * @returns {boolean} True if the url can be loaded.
25501
25508
  */
25502
25509
  dwv.io.RawImageLoader.prototype.canLoadUrl = function (url, options) {
25503
- // if there are options.requestHeaders, just base check on them
25510
+ // check options.requestHeaders for 'Accept'
25504
25511
  if (typeof options !== 'undefined' &&
25505
25512
  typeof options.requestHeaders !== 'undefined') {
25506
- // starts with 'image/'
25507
- var isImage = function (element) {
25508
- return element.name === 'Accept' &&
25509
- dwv.utils.startsWith(element.value, 'image/');
25513
+ var isNameAccept = function (element) {
25514
+ return element.name === 'Accept';
25510
25515
  };
25511
- return typeof options.requestHeaders.find(isImage) !== 'undefined';
25516
+ var acceptHeader = options.requestHeaders.find(isNameAccept);
25517
+ if (typeof acceptHeader !== 'undefined') {
25518
+ // starts with 'image/'
25519
+ return dwv.utils.startsWith(acceptHeader.value, 'image/');
25520
+ }
25512
25521
  }
25513
25522
 
25514
25523
  var urlObjext = dwv.utils.getUrlFromUri(url);
@@ -25729,15 +25738,17 @@ dwv.io.RawVideoLoader.prototype.canLoadFile = function (file) {
25729
25738
  * @returns {boolean} True if the url can be loaded.
25730
25739
  */
25731
25740
  dwv.io.RawVideoLoader.prototype.canLoadUrl = function (url, options) {
25732
- // if there are options.requestHeaders, just base check on them
25741
+ // check options.requestHeaders for 'Accept'
25733
25742
  if (typeof options !== 'undefined' &&
25734
25743
  typeof options.requestHeaders !== 'undefined') {
25735
- // starts with 'video/'
25736
- var isVideo = function (element) {
25737
- return element.name === 'Accept' &&
25738
- dwv.utils.startsWith(element.value, 'video/');
25744
+ var isNameAccept = function (element) {
25745
+ return element.name === 'Accept';
25739
25746
  };
25740
- return typeof options.requestHeaders.find(isVideo) !== 'undefined';
25747
+ var acceptHeader = options.requestHeaders.find(isNameAccept);
25748
+ if (typeof acceptHeader !== 'undefined') {
25749
+ // starts with 'video/'
25750
+ return dwv.utils.startsWith(acceptHeader.value, 'video/');
25751
+ }
25741
25752
  }
25742
25753
 
25743
25754
  var urlObjext = dwv.utils.getUrlFromUri(url);
@@ -27062,15 +27073,17 @@ dwv.io.ZipLoader.prototype.canLoadFile = function (file) {
27062
27073
  * @returns {boolean} True if the url can be loaded.
27063
27074
  */
27064
27075
  dwv.io.ZipLoader.prototype.canLoadUrl = function (url, options) {
27065
- // if there are options.requestHeaders, just base check on them
27076
+ // check options.requestHeaders for 'Accept'
27066
27077
  if (typeof options !== 'undefined' &&
27067
27078
  typeof options.requestHeaders !== 'undefined') {
27068
- // starts with 'application/zip'
27069
- var isZip = function (element) {
27070
- return element.name === 'Accept' &&
27071
- dwv.utils.startsWith(element.value, 'application/zip');
27079
+ var isNameAccept = function (element) {
27080
+ return element.name === 'Accept';
27072
27081
  };
27073
- return typeof options.requestHeaders.find(isZip) !== 'undefined';
27082
+ var acceptHeader = options.requestHeaders.find(isNameAccept);
27083
+ if (typeof acceptHeader !== 'undefined') {
27084
+ // starts with 'application/zip'
27085
+ return dwv.utils.startsWith(acceptHeader.value, 'application/zip');
27086
+ }
27074
27087
  }
27075
27088
 
27076
27089
  var urlObjext = dwv.utils.getUrlFromUri(url);