module Roda::RodaPlugins::UnescapePath

  1. lib/roda/plugins/unescape_path.rb

The unescape_path plugin decodes a URL-encoded path before routing. This fixes routing when the slashes are URL-encoded as %2f and returns decoded parameters when matched by symbols or regexps.

plugin :unescape_path

route do |r|
  # Assume /b/a URL encoded at %2f%62%2f%61
  r.on :x, /(.)/ do |*x|
    # x => ['b', 'a']
  end
end