<commit_before>const queryString = require('query-string')
const XHR = require('../lib/xhr')

const XhrLink = {
  selector: '.js-xhr',

  init (isGlobal = false) {
    this.isGlobal = isGlobal
    document.addEventListener('click', this.handleClick.bind(this))
  },

  handleClick (evt) {
    const target = evt.target || evt.srcElement
    const url = target.getAttribute('href')

    if (!url || url.match(/^http:\/\//)) { return }
    const path = url.match(/^(.*)\?/)[1]

    const hasXhrClass = target.classList.contains(this.selector.substring(1))
    const shouldXhr = target.tagName === 'A' && this.isGlobal ? true : hasXhrClass
    const params = queryString.parse(url)<commit_msg>Fix JS error in XHR link module<commit_after>const queryString = require('query-string')
const XHR = require('../lib/xhr')

const XhrLink = {
  selector: '.js-xhr',

  init (isGlobal = false) {
    this.isGlobal = isGlobal
    document.addEventListener('click', this.handleClick.bind(this))
  },

  handleClick (evt) {
    const target = evt.target || evt.srcElement
    const url = target.getAttribute('href')
    const hasXhrClass = target.classList.contains(this.selector.substring(1))
    const shouldXhr = target.tagName === 'A' && this.isGlobal ? true : hasXhrClass

    if (!url || url.match(/^http:\/\//)) { return }
    const path = url.replace(/(\?.*)/, '')

    const params = queryString.parse(url)
{'fraction_non_alphanumeric': 0.1657142857142857, 'fraction_numerical': 0.002142857142857143, 'mean_word_length': 3.5487012987012987, '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': '5548657', 'n_tokens_mistral': 449, 'n_tokens_neox': 448, 'n_words': 97}