Class: S3Cat::S3UrlParser

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_cat/s3_url_parser.rb

Constant Summary collapse

S3_URL_PATTERN =
%r{^s3://(?<bucket>\S+?)/(?<key>\S+)?$}.freeze

Instance Method Summary collapse

Instance Method Details

#parse_url(s3_url) ⇒ Object



7
8
9
10
11
# File 'lib/s3_cat/s3_url_parser.rb', line 7

def parse_url(s3_url)
  matched_data = S3_URL_PATTERN.match(s3_url)

  [matched_data['bucket'], matched_data['key']]
end