If I have URL A say http://www.example.com/
and another, say http://www.example.com
. What would be the safest way to determine if both is the same, without querying for the web page and do a diff?
EXAMPLES:
http://www.example.com/
VS http://www.example.com
(Mentioned above)http://www.example.com/aa/../
VS http://www.example.com
EDIT: Clarifications: Just want to know if the URLs are the same in the context of being equivalent according to the RFC 1738 standard.
In .Net, you can use the System.Uri class.
let u1 = new Uri("http://www.google.com/");;
val u1 : Uri = http://www.google.com/
let u2 = new Uri("http://www.google.com");;
val u2 : Uri = http://www.google.com/
u1.Equals(u2);;
val it : bool = true
For more fine-grained comparison, you can use the Uri.Compare method. There are also static methods to deal with various forms of escaping and encoding of characters in the Uri string, which will no doubt prove useful when dealing with the subject thoroughly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With