All files / atom/videoPlayer/src/hooks/vimeo useVimeoProperties.js

100% Statements 11/11
50% Branches 1/2
100% Functions 3/3
100% Lines 11/11

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    1x 6x 6x       6x     6x 6x 6x 6x 6x   6x     6x        
import {VIMEO} from '../../settings/players.js'
 
const useVimeoProperties = () => {
  const getEmbeddableUrl = src => {
    const videoSrc = _replaceNonEmbeddableUrl({
      src,
      nonEmbeddableUrl: VIMEO.SRC_PATTERNS[0]
    })
    return videoSrc
  }
 
  const _replaceNonEmbeddableUrl = ({src, nonEmbeddableUrl}) => {
    let videoSrc = src
    Eif (videoSrc.includes(nonEmbeddableUrl)) {
      const videoId = videoSrc.split(nonEmbeddableUrl)[1]
      videoSrc = `${VIMEO.EMBEDDABLE_URL}${videoId}`
    }
    return videoSrc
  }
 
  return {getEmbeddableUrl}
}
 
export default useVimeoProperties