lib/services/sites.js
function getSiteFromPrefix(prefix) {
  var split = prefix.split('/'), // Split the url/uri by `/`
    host = split.shift(),        // The first value should be the host ('http://' is not included)
    optPath = split.shift(),  // The next value is the first part of the site's path OR the whole part
    path = optPath ? `/${optPath}` : '',
    length = split.length + 1,   // We always need at least one pass through the for loop
    site;                        // Initialize the return value to `undefined`

  for (let i = 0; i < length; i++) {
    site = getSite(host, path); // Try to get the site based on the host and path

    if (site) { // If a site was found, break out of the loop
      break;
    } else {
      path += `/${split.shift()}`; // Grab the next value and append it to the `path` value
    }
  }

  return site; // Return the site
}
function getSiteFromPrefix(prefix) {
  var split = prefix.split('/'), // Split the url/uri by `/`
    host = split.shift(),        // The first value should be the host ('http://' is not included)
    optPath = split.shift(),  // The next value is the first part of the site's path OR the whole part
    path = optPath ? `/${optPath}` : '',
    length = split.length + 1,   // We always need at least one pass through the for loop
    site;                        // Initialize the return value to `undefined`

  for (let i = 0; i < length; i++) {
    site = getSite(host, path); // Try to get the site based on the host and path

    if (site) { // If a site was found, break out of the loop
      break;
    } else {
      path += `/${split.shift()}`; // Grab the next value and append it to the `path` value
    }
  }

  return site; // Return the site
}
function getSiteFromPrefix ( prefix ) { var split = prefix . split ( '/' ) , // Split the url/uri by `/` host = split . shift ( ) , // The first value should be the host ('http://' is not included) optPath = split . shift ( ) , // The next value is the first part of the site's path OR the whole part path = optPath ? ` ${ optPath } ` : '' , length = split . length + 1 , // We always need at least one pass through the for loop site ; // Initialize the return value to `undefined` for ( let i = 0 ; i < length ; i ++ ) { site = getSite ( host , path ) ; // Try to get the site based on the host and path if ( site ) { // If a site was found, break out of the loop break ; } else { path += ` ${ split . shift ( ) } ` ; // Grab the next value and append it to the `path` value } } return site ; // Return the site }
Get the site a URI belongs to

@param {string} prefix
@returns {object}
Get the site a URI belongs to