module Roda::RodaPlugins::MultibyteStringMatcher

  1. lib/roda/plugins/multibyte_string_matcher.rb

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)

  r.get /y-(#{path})/u do |x|
    # GET /y-\xD0\xB8 (request.path in UTF-8 format)
    x => "\xD0\xB8".force_encoding('BINARY')


Public Class

  1. load_dependencies

Public Class methods


Must load unescape_path plugin to decode multibyte paths, which are submitted escaped.

[show source]
   # File lib/roda/plugins/multibyte_string_matcher.rb
31 def self.load_dependencies(app)
32   app.plugin :unescape_path
33 end