On Thu, Jul 13, 2006 at 06:33:03PM +0200, Roland Weber wrote: > Hello Eugeny, > > > http://somedomain.com/path1?query1 and http://somedomain.com/path2?query2 > > should be considered as same url, but > why should /path1 be considered the same as /path2? > It doesn't make sense to me, but it doesn't have to.
Actually I need to provide a way to avoid users provide URLs which are pointing to the same website. > > http://somedomain.com/~username1 and http://somedomain.com/~username2 are > > not, > > > > and finally > > > > http://somedomain.com/~username1/path1 and > > http://somedomain.com/~username1/path2?query should be considered as same. > > > > Is there any way I can perform this validation using URI class? > > If you expect the URI class to figure out what anybody might consider > same or different, the answer is no. Sure I don't expect this ;) > If you understand that it is your > application that needs to do the comparison and the URI class is used > only to hold the URIs, the answer is yes. > What you have to do is to pick everything that is relevant for the > comparison, and remove everything that should be ignored. Such a step > is called normalization. Once you have your URLs normalized, you can > then use plain .equals() to check whether they are equal. Actually I did in this way, but I didn't find a way how I can set host in URI. For instance, I needed to remove "^www." if exists in URI, there is method getHost(), but no setHost(). So I finished with comparing strings created like this url.getSchema()+"://"+updateHost+url.getPath() And I don't like this approach. -- Eugene N Dzhurinsky --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
