All files / atom/videoPlayer/src/hooks/native useGetSrcWithMediaFragments.js

100% Statements 13/13
100% Branches 12/12
100% Functions 3/3
100% Lines 10/10

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 181x 26x 17x   9x 9x   9x 8x 8x 8x     1x        
const useGetSrcWithMediaFragments = ({videoSrc, timeOffset, timeLimit}) => {
  const isEmpty = param => param === undefined || param === null
  const isNotEmpty = param => !isEmpty(param)
 
  let timeOffsetParam = timeOffset
  if (isEmpty(timeOffset) && isNotEmpty(timeLimit)) timeOffsetParam = '0'
 
  if (isNotEmpty(videoSrc)) {
    const timeLimitParam = timeLimit ? `,${timeLimit}` : ''
    timeOffsetParam = timeOffsetParam ? `#t=${timeOffsetParam}` : ''
    return `${videoSrc}${timeOffsetParam}${timeLimitParam}`
  }
 
  return null
}
 
export default useGetSrcWithMediaFragments