I have two urls as Java Strings suppose “youtube.com” and “goo.gl/ur2l” and I want to make a function
boolean isSame(String url1, String url2)
which returns weather both urls direct to the same url at the end or not.
how would that be implemented in java ?
Do a HTTP request for each URL and check the HTTP code. If it’s a redirect (
30*), extract theLocationHTTP header, that should be the “original” URL.