<commit_before>import * as validator from '../../util/validation';
import * as note from '../../util/notificationManagement';
import {fieldSplit} from '../../util/names';

export function doValidation(segment, fieldName, text) {
  // could chain multiple validators, all that's required is we return a promise; could do more inbetween if desired
  switch (fieldName) {
    case 'latitude':
      return validator.validCoord(segment, fieldName, text, -90, 90);
    case 'longitude':
      return validator.validCoord(segment, fieldName, text, -180, 180);
    default:
      console.log('noop validation / type coercion for fieldName', fieldName);
      return validator.noop(segment, fieldName, text);
  }
}

export function referrerDomain() {
  const reg = /^https?:\/\/(.*):\d+/g;
  const match = reg.exec(document.referrer);

  if (match === null || match.length < 2) {
    console.log('failed to determine referrer domain, got', match);
    return '{hostname}';
  } else {
    return match[1];
  }
}<commit_msg>prefer window.location.href over document.referrer Fixes #15<commit_after>import * as validator from '../../util/validation';
import * as note from '../../util/notificationManagement';
import {fieldSplit} from '../../util/names';

export function doValidation(segment, fieldName, text) {
  // could chain multiple validators, all that's required is we return a promise; could do more inbetween if desired
  switch (fieldName) {
    case 'latitude':
      return validator.validCoord(segment, fieldName, text, -90, 90);
    case 'longitude':
      return validator.validCoord(segment, fieldName, text, -180, 180);
    default:
      console.log('noop validation / type coercion for fieldName', fieldName);
      return validator.noop(segment, fieldName, text);
  }
}

export function referrerDomain() {
  const reg = /^https?:\/\/(.*):\d+/g;
  const match = reg.exec(window.location.href);

  if (match === null || match.length < 2) {
    console.log('failed to determine referrer domain, got', match);
    return '{hostname}';
  } else {
    return match[1];
  }
}
{'fraction_non_alphanumeric': 0.14485081809432146, 'fraction_numerical': 0.012512030798845043, 'mean_word_length': 3.62, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3382109', 'n_tokens_mistral': 626, 'n_tokens_neox': 601, 'n_words': 191}