<commit_before>var request = require('request');
var express = require('express');
var cheerio = require('cheerio');
var http = require('http');
var fs = require('fs');

/* app */
var app = express();
var regions = ['kr','na','euw','eune','oce','br','ru','las','lan','tr'];
var options = {
  url: '',
  headers: {
    'Content-Type': 'text/html',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
    'Accept-Language': 'en-GB,en-US;q=0.8,en;q=0.6',
    'Cookie': 'oldLayout=true'
  }
};

app.param('region', function(req,res,next,id){
  if (regions.indexOf(req.params.region) == -1) {
    res.send({'status':'error','error':'invalid region'});
    return;
  }
  if (req.params.region == 'kr') {req.params.region = 'www';}
  options.region = req.params.region;
  next();
});

app.param('summoner', function(req,res,next,id){
  if (req.params.summoner.length > 16 || req.params.summoner.length < 3) {
    res.send({'status':'error','error':'invalid summoner name'});
    return;
  }
  next();
});

app.param('gamenum', function(req,res,next,id) {
  if (req.params.gamenum % 1 !== 0 || parseInt(req.params.gamenum) < 1000000000) {
    res.send({'status':'error','error':'invalid game number'});
    return;
  }
	options.gamenum = req.params.gamenum;
	next();
});

app.param('summonerId', function(req,res,next,id) {
  if (req.params.summonerId < 10000) {
    res.send({'status':'error','error':'invalid summoner id'});
    return;
  }
	options.summonerId = req.params.summonerId;
	next();
});

app.get('/:region/live', function(req,res){
  res.set('Content-Type', 'application/json');
  options.url = 'http://'+parseURL(req.params.region)+'.op.gg/spectate/pro/';
  console.log("parsing "+options.url);
  request(options,parseLiveFactory(res));
});

app.get('/:region/refresh/:summonerId', function(req,res) {
  res.set('Content-Type', 'application/json');
  options.url = 'http://na.op.gg/summoner/ajax/update.json/?summonerId='+parseURL(req.params.summonerId);
  console.log("parsing "+options.url);
  request(options,parseSummonerRefreshFactory(res));
});

app.get('/:region/summoner/:summoner', function(req,res) {
  res.set('Content-Type', 'application/json');
  options.url = 'http://'+parseURL(req.params.region)+'.op.gg/summoner/userName='+parseURL(req.params.summoner);
  console.log("parsing "+options.url);
  request(options,parseSummonerFactory(res));
});
<commit_msg>Fix refresh only targeting NA region<commit_after>var request = require('request');
var express = require('express');
var cheerio = require('cheerio');
var http = require('http');
var fs = require('fs');

/* app */
var app = express();
var regions = ['kr','na','euw','eune','oce','br','ru','las','lan','tr'];
var options = {
  url: '',
  headers: {
    'Content-Type': 'text/html',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
    'Accept-Language': 'en-GB,en-US;q=0.8,en;q=0.6',
    'Cookie': 'oldLayout=true'
  }
};

app.param('region', function(req,res,next,id){
  if (regions.indexOf(req.params.region) == -1) {
    res.send({'status':'error','error':'invalid region'});
    return;
  }
  if (req.params.region == 'kr') {req.params.region = 'www';}
  options.region = req.params.region;
  next();
});

app.param('summoner', function(req,res,next,id){
  if (req.params.summoner.length > 16 || req.params.summoner.length < 3) {
    res.send({'status':'error','error':'invalid summoner name'});
    return;
  }
  next();
});

app.param('gamenum', function(req,res,next,id) {
  if (req.params.gamenum % 1 !== 0 || parseInt(req.params.gamenum) < 1000000000) {
    res.send({'status':'error','error':'invalid game number'});
    return;
  }
	options.gamenum = req.params.gamenum;
	next();
});

app.param('summonerId', function(req,res,next,id) {
  if (req.params.summonerId < 10000) {
    res.send({'status':'error','error':'invalid summoner id'});
    return;
  }
	options.summonerId = req.params.summonerId;
	next();
});

app.get('/:region/live', function(req,res){
  res.set('Content-Type', 'application/json');
  options.url = 'http://'+parseURL(req.params.region)+'.op.gg/spectate/pro/';
  console.log("parsing "+options.url);
  request(options,parseLiveFactory(res));
});

app.get('/:region/refresh/:summonerId', function(req,res) {
  res.set('Content-Type', 'application/json');
  options.url = 'http://'+parseURL(req.params.region)+'.op.gg/summoner/ajax/update.json/?summonerId='+parseURL(req.params.summonerId);
  console.log("parsing "+options.url);
  request(options,parseSummonerRefreshFactory(res));
});

app.get('/:region/summoner/:summoner', function(req,res) {
  res.set('Content-Type', 'application/json');
  options.url = 'http://'+parseURL(req.params.region)+'.op.gg/summoner/userName='+parseURL(req.params.summoner);
  console.log("parsing "+options.url);
  request(options,parseSummonerFactory(res));
});

{'fraction_non_alphanumeric': 0.2246376811594203, 'fraction_numerical': 0.020531400966183576, 'mean_word_length': 5.030339805825243, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '698257', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1824, 'n_words': 257}