Sha256: cbb8a335d2d080de7c23914865a94f4609bd35d3a6de11dcbc9e915802398166
Contents?: true
Size: 888 Bytes
Versions: 10
Compression:
Stored size: 888 Bytes
Contents
# frozen_string_literal: true require "roda/plugins/public" # TODO: extract out to a standalone Roda plugin Roda::RodaPlugins::Public::RequestMethods.module_eval do SPLIT = Regexp.union(*[File::SEPARATOR, File::ALT_SEPARATOR].compact) # rubocop:disable Lint/ConstantDefinitionInBlock def public_path_segments(path) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity segments = [] path.split(SPLIT).each do |seg| next if seg.empty? || seg == "." seg == ".." ? segments.pop : segments << seg end path = File.join(roda_class.opts[:public_root], *segments) unless File.file?(path) path = File.join(path, "index.html") if File.file?(path) segments << "index.html" else segments[segments.size - 1] = "#{segments.last}.html" end end segments rescue IndexError nil end end
Version data entries
10 entries across 10 versions & 1 rubygems