tags:

views:

185

answers:

1

I'm looking for a method that will allow me to take two URL's and decide if one is in the scope of the other, meaning that it is either in the same folder or in a subdirectory beneath it. I could write the method myself if I had to, just wondering if anyone knew of something already in the ruby libraries.

Ex. of what I mean:
url1 = 'http://foo.com/bar/blah.html'
url2 = 'http://foo.com/bar/subbar/anotherfile.html'
url3 = 'http://foo.com/notbar/meh.html'

url2 is in the same scope as url1 (but not vice versa) and url3 is in the same scope as neither.

Thanks.

+2  A: 

http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/

Then you can explode the path and compare it leaving off the file name.

CodeJoust
awesome idea! that's a much simpler approach. thanks! :)
Jarsen