All files / platform/core/src/utils imageIdToURI.js

85.71% Statements 6/7
50% Branches 1/2
100% Functions 2/2
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                309023x   309023x               309023x     309023x     309023x     309023x    
/**
 * Removes the data loader scheme from the imageId
 *
 * @param {string} imageId Image ID
 * @returns {string} imageId without the data loader scheme
 * @memberof Cache
 */
export default function imageIdToURI(imageId) {
  const colonIndex = imageId.indexOf(':');
 
  return imageId.substring(colonIndex + 1);
}
 
/**
 * Normalizes an imageId to the metadata lookup key (scheme stripped, frame query removed).
 * Must match MetadataProvider.getUIDsFromImageID lookup behavior.
 */
export function baseImageURIForMetadata(imageId) {
  const urlRegex = /^(http|https|dicomfile):\/\//;
  let imageURI;
 
  Iif (urlRegex.test(imageId)) {
    imageURI = imageId;
  } else {
    imageURI = imageIdToURI(imageId);
  }
 
  return imageURI.split('&frame=')[0].split('?frame=')[0];
}