Files
news.gitea.happylizard.me/bin/gems/facets-3.1.0/lib/standard/facets/uri/decode.rb
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

33 lines
726 B
Ruby

require 'uri'
module URI
module_function
# Decode the uri components.
#
def decode(uri)
## gmosx: hmm is this needed?
## guard against invalid filenames for example pictures with
## spaces uploaded by users
escaped_uri = uri.gsub(/ /, "+")
if md = URI::REGEXP::REL_URI.match(escaped_uri)
path = "#{md[5]}#{md[6]}"
type = File.extname(path)
query_string = md[7]
## real_path = "#{$root_dir}/#{path}"
parameters = URI.query_to_hash(query_string)
path.gsub!(/\+/, " ")
return [path, type, parameters, query_string]
end
## this is usefull for uncovering bugs!
raise ArgumentError.new("the parameter '#{uri}' is not a valid uri")
end
end