Ruby url parsing - determine whether one url is under the same folder
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开发者_如何学C/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.
http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/
Then you can explode the path and compare it leaving off the file name.
精彩评论