rofrischmann/react-look

View on GitHub
packages/react-look/modules/utils/getFontFormat.js

Summary

Maintainability
A
0 mins
Test Coverage
const formats = {
  '.woff': 'woff',
  '.eof': 'eof',
  '.ttf': 'truetype',
  '.svg': 'svg'
}

// Returns the font format for a specific font source
export default function getFontFormat(src) {
  return Object.keys(formats).reduce((format, extension) => {
    if (src.indexOf(extension) > -1) {
      format = formats[extension]
    }
    return format; // eslint-disable-line
  }, undefined)
}