<commit_before>var Layers = require('./vis/layers');
var TileLayer = require('../geo/map/tile-layer');
var WMSLayer = require('../geo/map/wms-layer');
var GMapsBaseLayer = require('../geo/map/gmaps-base-layer');
var PlainLayer = require('../geo/map/plain-layer');
var CartoDBLayer = require('../geo/map/cartodb-layer');
var TorqueLayer = require('../geo/map/torque-layer');

/*
 *  if we are using http and the tiles of base map need to be fetched from
 *  https try to fix it
 */
var HTTPS_TO_HTTP = {
  'https://dnv9my2eseobd.cloudfront.net/': 'http://a.tiles.mapbox.com/',
  'https://maps.nlp.nokia.com/': 'http://maps.nlp.nokia.com/',
  'https://tile.stamen.com/': 'http://tile.stamen.com/',
  'https://{s}.maps.nlp.nokia.com/': 'http://{s}.maps.nlp.nokia.com/',
  'https://cartocdn_{s}.global.ssl.fastly.net/': 'http://{s}.api.cartocdn.com/',
  'https://cartodb-basemaps-{s}.global.ssl.fastly.net/': 'http://{s}.basemaps.cartocdn.com/'
};

function transformToHTTP (tilesTemplate) {
  for (var url in HTTPS_TO_HTTP) {
    if (tilesTemplate.indexOf(url) !== -1) {
      return tilesTemplate.replace(url, HTTPS_TO_HTTP[url]);
    }
  }
  return tilesTemplate;
}

function transformToHTTPS (tilesTemplate) {
  for (var url in HTTPS_TO_HTTP) {
    var httpsUrl = HTTPS_TO_HTTP[url];
    if (tilesTemplate.indexOf(httpsUrl) !== -1) {
      return tilesTemplate.replace(httpsUrl, url);
    }
  }
  return tilesTemplate;
}

Layers.register('tilejson', function (data, options) {
  var url = data.tiles[0];
  if (options.https === true) {
    url = transformToHTTPS(url);
  } else if (options.https === false) { // Checking for an explicit false value. If it's undefined the url is left as is.
    url = transformToHTTP(url);
  }
  return new TileLayer({
    urlTemplate: url
  });
});

Layers.register('tiled', function (data, options) {
  var url = data.urlTemplate;
  if (options.https === true) {
    url = transformToHTTPS(url);
  } else if (options.https === false) { // Checking for an explicit false value. If it's undefined the url is left as is.
    url = transformToHTTP(url);
  }

  data.urlTemplate = url;
  return new TileLayer(data);
});

Layers.register('wms', function (data, options) {
  return new WMSLayer(data);
});

Layers.register('gmapsbase', function (data, options) {
  return new GMapsBaseLayer(data);
});

Layers.register('plain', function (data, options) {
  return new PlainLayer(data);
});

Layers.register('background', function (data, options) {
  return new PlainLayer(data);
});

Layers.register('cartodb', function (data, options) {
  normalizeOptions(data, options);
  return new CartoDBLayer(data, {
    vis: options.vis
  });
});

Layers.register('torque', function (data, options) {
  normalizeOptions(data, options);
  // default is https
  if (options.https) {
    if (data.sql_api_domain && data.sql_api_domain.indexOf('carto.com') !== -1) {
      data.sql_api_protocol = 'https';
      data.sql_api_port = 443;
      data.tiler_protocol = 'https';
      data.tiler_port = 443;
    }
  }
  return new TorqueLayer(data, {
    vis: options.vis
  });
});

function normalizeOptions (data, options) {
  if (data.infowindow && data.infowindow.fields) {
    if (data.interactivity) {
      if (data.interactivity.indexOf('cartodb_id') === -1) {
        data.interactivity = data.interactivity + ',cartodb_id';
      }
    } else {
      data.interactivity = 'cartodb_id';
    }
  }
}

module.exports = Layers;<commit_msg>No need to "normalizeOptions" anymore:<commit_after>var Layers = require('./vis/layers');
var TileLayer = require('../geo/map/tile-layer');
var WMSLayer = require('../geo/map/wms-layer');
var GMapsBaseLayer = require('../geo/map/gmaps-base-layer');
var PlainLayer = require('../geo/map/plain-layer');
var CartoDBLayer = require('../geo/map/cartodb-layer');
var TorqueLayer = require('../geo/map/torque-layer');

/*
 *  if we are using http and the tiles of base map need to be fetched from
 *  https try to fix it
 */
var HTTPS_TO_HTTP = {
  'https://dnv9my2eseobd.cloudfront.net/': 'http://a.tiles.mapbox.com/',
  'https://maps.nlp.nokia.com/': 'http://maps.nlp.nokia.com/',
  'https://tile.stamen.com/': 'http://tile.stamen.com/',
  'https://{s}.maps.nlp.nokia.com/': 'http://{s}.maps.nlp.nokia.com/',
  'https://cartocdn_{s}.global.ssl.fastly.net/': 'http://{s}.api.cartocdn.com/',
  'https://cartodb-basemaps-{s}.global.ssl.fastly.net/': 'http://{s}.basemaps.cartocdn.com/'
};

function transformToHTTP (tilesTemplate) {
  for (var url in HTTPS_TO_HTTP) {
    if (tilesTemplate.indexOf(url) !== -1) {
      return tilesTemplate.replace(url, HTTPS_TO_HTTP[url]);
    }
  }
  return tilesTemplate;
}

function transformToHTTPS (tilesTemplate) {
  for (var url in HTTPS_TO_HTTP) {
    var httpsUrl = HTTPS_TO_HTTP[url];
    if (tilesTemplate.indexOf(httpsUrl) !== -1) {
      return tilesTemplate.replace(httpsUrl, url);
    }
  }
  return tilesTemplate;
}

Layers.register('tilejson', function (data, options) {
  var url = data.tiles[0];
  if (options.https === true) {
    url = transformToHTTPS(url);
  } else if (options.https === false) { // Checking for an explicit false value. If it's undefined the url is left as is.
    url = transformToHTTP(url);
  }
  return new TileLayer({
    urlTemplate: url
  });
});

Layers.register('tiled', function (data, options) {
  var url = data.urlTemplate;
  if (options.https === true) {
    url = transformToHTTPS(url);
  } else if (options.https === false) { // Checking for an explicit false value. If it's undefined the url is left as is.
    url = transformToHTTP(url);
  }

  data.urlTemplate = url;
  return new TileLayer(data);
});

Layers.register('wms', function (data, options) {
  return new WMSLayer(data);
});

Layers.register('gmapsbase', function (data, options) {
  return new GMapsBaseLayer(data);
});

Layers.register('plain', function (data, options) {
  return new PlainLayer(data);
});

Layers.register('background', function (data, options) {
  return new PlainLayer(data);
});

Layers.register('cartodb', function (data, options) {
  return new CartoDBLayer(data, {
    vis: options.vis
  });
});

Layers.register('torque', function (data, options) {
  // default is https
  if (options.https) {
    if (data.sql_api_domain && data.sql_api_domain.indexOf('carto.com') !== -1) {
      data.sql_api_protocol = 'https';
      data.sql_api_port = 443;
      data.tiler_protocol = 'https';
      data.tiler_port = 443;
    }
  }
  return new TorqueLayer(data, {
    vis: options.vis
  });
});

module.exports = Layers;
{'fraction_non_alphanumeric': 0.17143294081663862, 'fraction_numerical': 0.00382321455880104, 'mean_word_length': 3.6415897799858055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 12, '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': '1730257', 'n_tokens_mistral': 2346, 'n_tokens_neox': 2288, 'n_words': 489}