<commit_before>'use strict';

var url = require('url');

var ApiAuthRequestError = require('../error/ApiAuthRequestError');

function AuthRequestParser(request,locationsToSearch){

  if(typeof request !=='object'){
    throw new ApiAuthRequestError('request must be an object');
  }
  if(typeof request.url !== 'string'){
    throw new ApiAuthRequestError('request must have a url string');
  }
  if(typeof request.headers !== 'object'){
    throw new ApiAuthRequestError('request must have a headers object');
  }
  if(typeof request.method !== 'string'){
    throw new ApiAuthRequestError('request must have a method property');
  }
  if(typeof locationsToSearch !== 'object') {
    throw new ApiAuthRequestError('locationsToSearch must be an array');
  }

  var req = request;
  var searchBody = locationsToSearch.indexOf('body') > -1;
  var searchHeader = locationsToSearch.indexOf('header') > -1;
  var searchUrl = locationsToSearch.indexOf('url') > -1;

  var urlParams = url.parse(req.url,true).query;

  this.body = (searchBody && typeof (req.body === 'object') && (req.body !== null)) ? req.body : {};
  this.headers = searchHeader ? req.headers : {};

  this.grantType = this.body.grant_type || urlParams.grant_type || '';
  this.authorizationValue = searchHeader ?
    (this.headers['authorization'] || this.headers['Authorization'] || '') : '';
  this.accessToken = searchUrl ?
    (urlParams.access_token || this.body.access_token || this.authorizationValue) :
      (this.body.access_token || this.authorizationValue);

  this.requestedScope = (this.body.scope || urlParams.scope || '').split(' ');
}

module.exports = AuthRequestParser;<commit_msg>Fixing expressions.<commit_after>'use strict';

var url = require('url');

var ApiAuthRequestError = require('../error/ApiAuthRequestError');

function AuthRequestParser(request,locationsToSearch){

  if(typeof request !=='object'){
    throw new ApiAuthRequestError('request must be an object');
  }
  if(typeof request.url !== 'string'){
    throw new ApiAuthRequestError('request must have a url string');
  }
  if(typeof request.headers !== 'object'){
    throw new ApiAuthRequestError('request must have a headers object');
  }
  if(typeof request.method !== 'string'){
    throw new ApiAuthRequestError('request must have a method property');
  }
  if(typeof locationsToSearch !== 'object') {
    throw new ApiAuthRequestError('locationsToSearch must be an array');
  }

  var req = request;
  var searchBody = locationsToSearch.indexOf('body') > -1;
  var searchHeader = locationsToSearch.indexOf('header') > -1;
  var searchUrl = locationsToSearch.indexOf('url') > -1;

  var urlParams = url.parse(req.url,true).query;

  this.body = (searchBody && (typeof (req.body === 'object')) && (req.body !== null)) ? req.body : {};
  this.headers = searchHeader ? req.headers : {};

  this.grantType = this.body.grant_type || urlParams.grant_type || '';
  this.authorizationValue = searchHeader ?
    (this.headers['authorization'] || this.headers['Authorization'] || '') : '';
  this.accessToken = searchUrl ?
    (urlParams.access_token || this.body.access_token || this.authorizationValue) :
      (this.body.access_token || this.authorizationValue);

  this.requestedScope = (this.body.scope || urlParams.scope || '').split(' ');
}

module.exports = AuthRequestParser;
{'fraction_non_alphanumeric': 0.15326934613077384, 'fraction_numerical': 0.001799640071985603, 'mean_word_length': 4.623946037099494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4097545', 'n_tokens_mistral': 986, 'n_tokens_neox': 976, 'n_words': 224}