Consider adding a helper class/method to deal with URL validations. This pattern seems to be present in at least two files.