This feels like an XY Problem, though. What are you trying to achieve by checking if the URL is valid?