code: function(endpoint) {
              var patterns = [
                      //bucket in domain
                      /^(?:https?:\/\/)?([a-z0-9.\-_]+)\.s3(?:-[a-z0-9\-]+)?\.amazonaws\.com/i,
                      //bucket in path
                      /^(?:https?:\/\/)?s3(?:-[a-z0-9\-]+)?\.amazonaws\.com\/([a-z0-9.\-_]+)/i,
                      //custom domain
                      /^(?:https?:\/\/)?([a-z0-9.\-_]+)/i
                  ],
                  bucket;
  
              qq.each(patterns, function(idx, pattern) {
                  var match = pattern.exec(endpoint);
  
                  if (match) {
                      bucket = match[1];
                      return false;
                  }
              });
  
              return bucket;
          }
docs: This allows for the region to be specified in the bucket's endpoint URL, or not.
  
  Examples of some valid endpoints are:
  http://foo.s3.amazonaws.com
  https://foo.s3.amazonaws.com
  http://foo.s3-ap-northeast-1.amazonaws.com
  foo.s3.amazonaws.com
  http://foo.bar.com
  http://s3.amazonaws.com/foo.bar.com
  ...etc
  
  @param endpoint The bucket's URL.
  @returns {String || undefined} The bucket name, or undefined if the URL cannot be parsed.