Module: Roda::RodaPlugins::MultibyteStringMatcher
- Defined in:
- lib/roda/plugins/multibyte_string_matcher.rb
Overview
The multibyte_string_matcher plugin allows multibyte strings to be used in matchers. Roda’s default string matcher does not handle multibyte strings for performance reasons.
As browsers send multibyte characters in request paths URL escaped, so this also loads the unescape_path plugin to unescape the paths.
plugin :multibyte_string_matcher
path = "\xD0\xB8".force_encoding('UTF-8')
route do |r|
r.get path do
# GET /\xD0\xB8 (request.path in UTF-8 format)
end
r.get /y-(#{path})/u do |x|
# GET /y-\xD0\xB8 (request.path in UTF-8 format)
x => "\xD0\xB8".force_encoding('BINARY')
end
end
Defined Under Namespace
Modules: RequestMethods
Class Method Summary collapse
-
.load_dependencies(app) ⇒ Object
Must load unescape_path plugin to decode multibyte paths, which are submitted escaped.
Class Method Details
.load_dependencies(app) ⇒ Object
Must load unescape_path plugin to decode multibyte paths, which are submitted escaped.
31 32 33 |
# File 'lib/roda/plugins/multibyte_string_matcher.rb', line 31 def self.load_dependencies(app) app.plugin :unescape_path end |