lib/roda/plugins/route_csrf.rb
# Given a form action, return the appropriate path to use for the CSRF token.
# This makes it easier to generate request-specific tokens without having to
# worry about the different types of form actions (relative paths, absolute
# paths, URLs, empty paths).
Given a form action, return the appropriate path to use for the CSRF token.
This makes it easier to generate request-specific tokens without having to
worry about the different types of form actions (relative paths, absolute
paths, URLs, empty paths).
Given a form action return the appropriate path to use for the CSRF token . This makes it easier to generate request - specific tokens without having to worry about the different types of form actions ( relative paths absolute paths URLs empty paths ) .
def csrf_path(action)
          case action
          when nil, '', /\A[#?]/
            request.path
          when /\A(?:https?:\/)?\//
            URI.parse(action).path
          else
            URI.join(request.url, action).path
          end
        end
def csrf_path ( action ) case action when nil , '' , / \A [#?] / request . path when / \A (?:https?: \/ )? \/ / URI . parse ( action ) . path else URI . join ( request . url , action ) . path end end
Given a form action, return the appropriate path to use for the CSRF token.
Given a form action return the appropriate path to use for the CSRF token .
# use current path # Either full URI or absolute path, extract just the path # relative path, join to current path
action