<commit_before>var querystring = require('querystring');
var url = require('url');
var MediaType = require('api-media-type');
var querytopic = require('../query_topic');
var streams = require('zetta-streams');
var ObjectStream = streams.ObjectStream;

var ServerResource = module.exports = function(server) {
  this.server = server;
  this.httpScout = this.server.httpScout;
  this.deviceTypes = [];
  this.typeIndex = [];
  this._listeners = {};
};

ServerResource.prototype.getServer = function(env) {
  var parsed = url.parse(env.request.url);
  var re = /^\/servers\/([^\/]+)/;
  var match = re.exec(parsed.pathname);
  
  var serverId = match && match[1] ? match[1] : this.server.id;

  return { path: '/servers/' + encodeURI(serverId) };
};

ServerResource.prototype.init = function(config) {
  config
    .path('/servers')
    .produces(MediaType.SIREN)
    .consumes(MediaType.FORM_URLENCODED)
    .consumes(MediaType.MULTIPART_FORM_DATA)
    .consumes(MediaType.JSON)
    .get('/{serverId}', this.showServer)
    .get('/{serverId}/devices/{deviceId}', this.showDevice)
    .put('/{serverId}/devices/{deviceId}', this.updateDevice)
    .del('/{serverId}/devices/{deviceId}', this.destroyDevice)
    .post('/{serverId}/devices/{deviceId}', this.deviceAction)
    .post('/{serverId}/devices', this.addRemoteDevice)
    .get('/{serverId}/events', this.subscribe)
    .post('/{serverId}/events/unsubscribe', this.unsubscribe)
    .get('/{serverId}/meta', this.showMetadata)
    .get('/{serverId}/meta/{type}', this.showMetadataType);

  this.listenForMetadata();
};
<commit_msg>Fixed issue with spaces in hub names<commit_after>var querystring = require('querystring');
var url = require('url');
var MediaType = require('api-media-type');
var querytopic = require('../query_topic');
var streams = require('zetta-streams');
var ObjectStream = streams.ObjectStream;

var ServerResource = module.exports = function(server) {
  this.server = server;
  this.httpScout = this.server.httpScout;
  this.deviceTypes = [];
  this.typeIndex = [];
  this._listeners = {};
};

ServerResource.prototype.getServer = function(env) {
  var parsed = url.parse(env.request.url);
  var re = /^\/servers\/([^\/]+)/;
  var match = re.exec(parsed.pathname);
  
  var serverId = match && match[1] ? decodeURI(match[1]) : this.server.id;

  return { path: '/servers/' + encodeURI(serverId) };
};

ServerResource.prototype.init = function(config) {
  config
    .path('/servers')
    .produces(MediaType.SIREN)
    .consumes(MediaType.FORM_URLENCODED)
    .consumes(MediaType.MULTIPART_FORM_DATA)
    .consumes(MediaType.JSON)
    .get('/{serverId}', this.showServer)
    .get('/{serverId}/devices/{deviceId}', this.showDevice)
    .put('/{serverId}/devices/{deviceId}', this.updateDevice)
    .del('/{serverId}/devices/{deviceId}', this.destroyDevice)
    .post('/{serverId}/devices/{deviceId}', this.deviceAction)
    .post('/{serverId}/devices', this.addRemoteDevice)
    .get('/{serverId}/events', this.subscribe)
    .post('/{serverId}/events/unsubscribe', this.unsubscribe)
    .get('/{serverId}/meta', this.showMetadata)
    .get('/{serverId}/meta/{type}', this.showMetadataType);

  this.listenForMetadata();
};

{'fraction_non_alphanumeric': 0.18449030644152595, 'fraction_numerical': 0.0012507817385866166, 'mean_word_length': 4.322795341098169, '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': '2240112', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1053, 'n_words': 164}