Handle more general URIs

Changed the line to check if a URL is valid to handle more cases.