All files parseImageId.js

0% Statements 0/8
0% Branches 0/2
0% Functions 0/1
0% Lines 0/8

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                                             
function parseImageId (imageId) {
  // build a url by parsing out the url scheme and frame index from the imageId
  const firstColonIndex = imageId.indexOf(':');
  let url = imageId.substring(firstColonIndex + 1);
  const frameIndex = url.indexOf('frame=');
  let frame;
 
  if (frameIndex !== -1) {
    const frameStr = url.substr(frameIndex + 6);
 
    frame = parseInt(frameStr, 10);
    url = url.substr(0, frameIndex - 1);
  }
 
  return {
    scheme: imageId.substr(0, firstColonIndex),
    url,
    frame
  };
}
 
export default parseImageId;