class S3Toolkit::UrlParser

Public Class Methods

call(s3_url) click to toggle source
# File lib/s3-toolkit/url_parser.rb, line 5
def self.call(s3_url)
  raise URI::InvalidURIError, "Unexpected format, expected: s3://<bucket>/<key>" unless s3_url&.start_with?("s3://")

  uri = URI.parse(s3_url)
  bucket = uri.host
  key = uri.path[1..] # Strip the leading /

  [bucket, key]
end