i would use this trick http://stackoverflow.com/a/6644749/64949 and then compare the protocol and hostname separately.