Sha256: 4314c1f04499a00ea391d587f599fb624c0355d0e2d2da1d41eb735b5db59e44
Contents?: true
Size: 725 Bytes
Versions: 6
Compression:
Stored size: 725 Bytes
Contents
module Locomotive::Steam module Middlewares # Sanitize the path from the previous middleware in order # to make it work for the renderer. # class Path attr_accessor_initialize :app def call(env) set_path!(env) app.call(env) end protected def set_path!(env) site = env['steam.site'] path = env['steam.path'].dup if site.allow_dots_in_slugs path.gsub!(/\.(html|htm)$/, '') else path.gsub!(/\.[a-zA-Z][a-zA-Z0-9]{2,}$/, '') end path.gsub!(/^\//, '') path.gsub!(/^[A-Z]:\//, '') path = 'index' if path.blank? env['steam.path'] = path end end end end
Version data entries
6 entries across 6 versions & 1 rubygems