Class: S3AssetDeploy::AssetHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_asset_deploy/asset_helper.rb

Constant Summary collapse

FINGERPRINTED_ASSET_REGEX =
/\A(.*)-([[:alnum:]]+)((?:(?:\.[[:alnum:]]+))+)\z/.freeze

Class Method Summary collapse

Class Method Details

.mime_type_for_path(path) ⇒ Object



14
15
16
17
18
# File 'lib/s3_asset_deploy/asset_helper.rb', line 14

def self.mime_type_for_path(path)
  extension = File.extname(path)[1..-1]
  return "application/json" if extension == "map"
  MIME::Types.type_for(extension).first
end

.remove_fingerprint(path) ⇒ Object



8
9
10
11
12
# File 'lib/s3_asset_deploy/asset_helper.rb', line 8

def self.remove_fingerprint(path)
  match_data = path.match(FINGERPRINTED_ASSET_REGEX)
  return path unless match_data
  "#{match_data[1]}#{match_data[3]}"
end