Better handling of invalid URL validation (fix CocoaPods/CocoaPods#2197)