lib/endpoints.js
function getEndpoint(origin, locale, path) {
  const validOrigin = Object.prototype.hasOwnProperty.call(endpoints, origin) ? origin : 'us';
  const endpoint = endpoints[validOrigin];

  return Object.assign(
    {},
    { origin: validOrigin },
    { hostname: origin === 'cn' ? endpoint.hostname : getPathHostName(validOrigin, path) },
    { locale: endpoint.locales.find(item => item === locale) || endpoint.defaultLocale },
  );
}
function getEndpoint(origin, locale, path) {
  const validOrigin = Object.prototype.hasOwnProperty.call(endpoints, origin) ? origin : 'us';
  const endpoint = endpoints[validOrigin];

  return Object.assign(
    {},
    { origin: validOrigin },
    { hostname: origin === 'cn' ? endpoint.hostname : getPathHostName(validOrigin, path) },
    { locale: endpoint.locales.find(item => item === locale) || endpoint.defaultLocale },
  );
}
function getEndpoint ( origin , locale , path ) { const validOrigin = Object . prototype . hasOwnProperty . call ( endpoints , origin ) ? origin : 'us' ; const endpoint = endpoints [ validOrigin ] ; return Object . assign ( { } , { origin : validOrigin } , { hostname : origin === 'cn' ? endpoint . hostname : getPathHostName ( validOrigin , path ) } , { locale : endpoint . locales . find ( item => item === locale ) || endpoint . defaultLocale } , ) ; }
Get the endpoint for a given region.

@param  {String} [origin] A regional origin
@param  {String} [locale] A regional locale
@param  {String} [path] A requested API path
@return {Object} The endpoint data object
Get the endpoint for a given region .