0

I want to retrieve the actual, encoded URL value for a page I visit in my Rails application.

So, if I visit http://domain.com/dir/test%2Bpath, I should get the value "http://domain.com/dir/test%2Bpath" and NOT "http://domain.com/dir/test+path".

Is there ANY way to do this? I've inspected the Request object, Googled...nothing.

Chad Johnson
  • 21,215
  • 34
  • 109
  • 207

2 Answers2

1

In my system I can use request.url and request.path:

(rdb:1) request.url
"http://localhost:3000/test2/path/a%2Bb"
(rdb:1) request.path
"/test2/path/a%2Bb"

This should work in the controller or the view.

Michael Slade
  • 13,802
  • 2
  • 39
  • 44
0

You can use ruby helper method

URI.unescape('http://domain.com/dir/test%2Bpath')
naren
  • 937
  • 1
  • 6
  • 21
  • I don't want to use any helpers; I want to retrieve the value directly from Request (or whatever) without any alteration from me, and I want that value to be encoded. – Chad Johnson Apr 27 '12 at 01:56