<commit_before>import React from 'react';
import queryString from 'query-string';
import {
  Grid, Row, Col,
  Glyphicon,
  ControlLabel, Form,
  Modal,
  OverlayTrigger, Popover, Button
} from 'react-bootstrap';
import {Link} from 'react-router-dom';

import {SearchFaq} from '../../components/SearchFaq.jsx';
import {SearchBar} from '../../components/SearchBar.jsx';

// SearchHeader
// Prop Dependencies ::
// - embed

export class SearchHeader extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      query: {
        q:'',
        gt: 3,
        lt: 250,
        type: 'Pathway'
      },
      showFilterMenu: false,
      showSearchFaq: false
    };
  }

  submitSearchQuery(e) {
    const state = this.state;
    const props = this.props;
    const uriRegex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/;

    const isUri = state.query.q.match(uriRegex) || decodeURIComponent(state.query.q).match(uriRegex);
    if (isUri) {
      props.history.push({
        pathname: '/view',
        search: queryString.stringify({uri: state.query.q}),
        state: {}
      });
    } else {
      props.history.push({
        pathname: '/search',
        search: queryString.stringify(state.query),
        state: {}
      });
    }
    e.target.blur();
  }

  onSearchValueChange(e) {
    // if the user presses enter, submit the query
    if (e.which && e.which ===  13) {
      this.submitSearchQuery(e);
    } else {
      const newQueryState = {...this.state.query};
      newQueryState.q = e.target.value;
      this.setState({query: newQueryState});
    }
  }

  toggleSearchFaq() {
    this.setState({
      showSearchFaq: !this.state.showSearchFaq
    });
  }

  showExampleQuery() {
    const newQueryState = {...this.state.query};
    newQueryState.q = 'ACVR2A BMP2 BMPR1B SMAD4';
    this.setState({query: newQueryState});
  }

  updateSearchQuery(query) {
    const props = this.props;
    const state = this.state;
    const uriRegex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/;
    console.log(query);
    if (query.q.match(uriRegex)) {
      props.history.push({
        pathname: '/view',
        search: queryString.stringify({uri: state.query.q}),
        state: {}
      });
    } else {<commit_msg>Remove log statement<commit_after>import React from 'react';
import queryString from 'query-string';
import {
  Grid, Row, Col,
  Glyphicon,
  ControlLabel, Form,
  Modal,
  OverlayTrigger, Popover, Button
} from 'react-bootstrap';
import {Link} from 'react-router-dom';

import {SearchFaq} from '../../components/SearchFaq.jsx';
import {SearchBar} from '../../components/SearchBar.jsx';

// SearchHeader
// Prop Dependencies ::
// - embed

export class SearchHeader extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      query: {
        q:'',
        gt: 3,
        lt: 250,
        type: 'Pathway'
      },
      showFilterMenu: false,
      showSearchFaq: false
    };
  }

  submitSearchQuery(e) {
    const state = this.state;
    const props = this.props;
    const uriRegex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/;

    const isUri = state.query.q.match(uriRegex) || decodeURIComponent(state.query.q).match(uriRegex);
    if (isUri) {
      props.history.push({
        pathname: '/view',
        search: queryString.stringify({uri: state.query.q}),
        state: {}
      });
    } else {
      props.history.push({
        pathname: '/search',
        search: queryString.stringify(state.query),
        state: {}
      });
    }
    e.target.blur();
  }

  onSearchValueChange(e) {
    // if the user presses enter, submit the query
    if (e.which && e.which ===  13) {
      this.submitSearchQuery(e);
    } else {
      const newQueryState = {...this.state.query};
      newQueryState.q = e.target.value;
      this.setState({query: newQueryState});
    }
  }

  toggleSearchFaq() {
    this.setState({
      showSearchFaq: !this.state.showSearchFaq
    });
  }

  showExampleQuery() {
    const newQueryState = {...this.state.query};
    newQueryState.q = 'ACVR2A BMP2 BMPR1B SMAD4';
    this.setState({query: newQueryState});
  }

  updateSearchQuery(query) {
    const props = this.props;
    const state = this.state;
    const uriRegex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/;

    if (query.q.match(uriRegex)) {
      props.history.push({
        pathname: '/view',
        search: queryString.stringify({uri: state.query.q}),
        state: {}
      });
    } else {
{'fraction_non_alphanumeric': 0.19706770159551532, 'fraction_numerical': 0.004312203536006899, 'mean_word_length': 2.4010263929618767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '963056', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1586, 'n_words': 293}