Class: Booth::Requests::ReturnPath
- Inherits:
-
Object
- Object
- Booth::Requests::ReturnPath
- Includes:
- Logging, Calls
- Defined in:
- lib/booth/requests/return_path.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/booth/requests/return_path.rb', line 11 def call uri = ::URI.parse raw_return_path # Make sure we do not redirect to (external) URLs but only paths (i.e. protocol and domain-local). result = [uri.path, uri.query].compact.join '?' # We usually never store the return path in a cookie, but some developer might still try it. # To avoid potential cookie overflows, allow only as many characters as reasonably needed. result = result[0..1024] return if result.blank? # We always assume it is a full path and fix any missing beginning slash. result.starts_with?('/') ? result : result.prepend('/') rescue URI::InvalidURIError log { "Invalid return path: #{raw_return_path.inspect}" } if raw_return_path nil end |