Here's a simple problem - given two urls, is there some built-in method, or an Apache library that decides whether they are (logically) equal?
For example, these two urls are equal:
http://stackoverflow.com
http://stackoverflow.com/
Here's a simple problem - given two urls, is there some built-in method, or an Apache library that decides whether they are (logically) equal?
For example, these two urls are equal:
http://stackoverflow.com
http://stackoverflow.com/
While
URI.equals()
(as well as the problematicURL.equals()
) does not returntrue
for these specific examples, I think it's the only case where equivalence can be assumed (because there is no empty path in the HTTP protocol).The URIs
http://stackoverflow.com/foo
andhttp://stackoverflow.com/foo/
can not be assumed to be equivalent.Maybe you can use
URI.equals()
wrapped in a utility method that handles this specific case explicitly.The following may work for you - it validates that 2 urls are equal, allows the parameters to be supplied in different orders, and allows a variety of options to be configured, that being:
You can test it like so:
UrlComparer.java
sameFile
excluding the fragment component. Returns true if this URL and the other argument are equal without taking the fragment component into consideration.
Parameters: other - the URL to compare against. Returns: true if they reference the same remote object; false otherwise.
also please go through this link
As iam unable to add comment , browser throwing Javascript error. so iam adding my comment here. regret for inconvience.
//this what i suggeted
so Joachim Sauer check once.
URL::equals reference
Note from docs -
So, instead you should prefer URI::equals reference as @Joachim suggested.