class ActionDispatch::Request

def original_fullpath

request.original_fullpath # => '/foo?bar'
# get '/foo?bar'

request.original_fullpath # => '/foo'
# get '/foo'

Returns a `String` with the last requested path including their params.
def original_fullpath
  @original_fullpath ||= (get_header("ORIGINAL_FULLPATH") || fullpath)
end