Merge pull request #51 from timdsnap/master

Upgrade for modern ruby
This commit is contained in:
Joshua Hull 2022-09-29 22:05:52 +00:00 committed by GitHub
commit 634245d569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -36,13 +36,13 @@ class HttpRouter
instance_eval <<-EOT, __FILE__, __LINE__ + 1
def generate(args, options)
generated_path = \"#{code}\"
#{validation_regex.inspect}.match(generated_path) ? URI.escape(generated_path) : nil
#{validation_regex.inspect}.match(generated_path) ? URI::DEFAULT_PARSER.escape(generated_path) : nil
end
EOT
else
instance_eval <<-EOT, __FILE__, __LINE__ + 1
def generate(args, options)
URI.escape(\"#{code}\")
URI::DEFAULT_PARSER.escape(\"#{code}\")
end
EOT
end
@ -147,4 +147,4 @@ class HttpRouter
uri
end
end
end
end

View File

@ -7,7 +7,7 @@ class HttpRouter
def initialize(path, rack_request)
@rack_request = rack_request
@path = URI.unescape(path).split(/\//)
@path = URI::DEFAULT_PARSER.unescape(path).split(/\//)
@path.shift if @path.first == ''
@path.push('') if path[-1] == ?/
@extra_env = {}
@ -27,4 +27,4 @@ class HttpRouter
@path.size == 0 or @path.size == 1 && @path.first == ''
end
end
end
end