<commit_before>import React, {PropTypes, Component} from 'react'
import withStyles from 'isomorphic-style-loader/lib/withStyles'
import s from './PreviewUrl.scss'
import {connect} from 'react-redux'
import URIJS from 'urijs'
import GithubIssuePreview from '../GithubIssuePreview'
// const messages = defineMessages({
//   previewUrlText: {
//     id: 'previewUrl.previewUrlText',
//     defaultMessage: 'PreviewUrl {customText}',
//     description: 'Preview url Description'
//   }
// })

class PreviewUrl extends Component {
  constructor (props) {
    super(props)
  }
  // TODO
  /*
    identify url website
    switch between types of url previews
    call component based on that
  */
  identifyURL (url) {
    switch (url) {
      case 'https://github.com/cassioscabral/rateissuesfront/issues/1': // Github issue
        return <GithubIssuePreview url={ url }></GithubIssuePreview>
      default:
        return url
    }
  }
  render () {
    let {url} = this.props
    return (
      <div className={ s.root }>
        { this.identifyURL(url) }
      </div>
    )
  }
}
<commit_msg>add regex to match github preview links<commit_after>import React, {PropTypes, Component} from 'react'
import withStyles from 'isomorphic-style-loader/lib/withStyles'
import s from './PreviewUrl.scss'
import {connect} from 'react-redux'
import GithubIssuePreview from '../GithubIssuePreview'

function isDomain (domain, url) {
    var pat = '^https?://(?:[^/@:]*:[^/@]*@)?(?:[^/:]+\.)?' + domain + '(?=[/:]|$)'
    var re = new RegExp(pat, 'i')
    return re.test(url)
}

class PreviewUrl extends Component {
  constructor (props) {
    super(props)
  }
  /*
    identify url website
    switch between types of url previews
    call component based on that
  */
  identifyURL (url) {
    if (isDomain('github.com', url)) {
      return <GithubIssuePreview url={ url }></GithubIssuePreview>
    }

    return url
  }
  render () {
    let {url} = this.props
    return (
      <div className={ s.root }>
        { this.identifyURL(url) }
      </div>
    )
  }
}

{'fraction_non_alphanumeric': 0.14264849074975658, 'fraction_numerical': 0.0004868549172346641, 'mean_word_length': 2.951923076923077, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3733921', 'n_tokens_mistral': 663, 'n_tokens_neox': 654, 'n_words': 173}