updated function with hasPrefix to check for http