perfectline / validates_url

URL Validation for Rails
MIT License
580 stars 112 forks source link

Errors when validating nil #76

Closed SirRawlins closed 5 years ago

SirRawlins commented 5 years ago

Hey Folks,

Just updated to the latest release (1.0.6), and noticed that when validating 'nil' it now errors with NoMethodError: undefined method gsub for nil:NilClass, rather than gracefully failing validation.

Running the tests for the gem seem to confirm this, so I guess this bug just got missed during the release process?

Finished in 0.28199 seconds (files took 1.13 seconds to load) 37 examples, 1 failure

Failed examples:

rspec ./spec/validate_url_spec.rb:24 # URL validation with regular validator does not allow nil as url

It looks like like this recent patch from @coneybeare is where things stopped working.

When URI.escape is passed the nil value you get the gdub error.

I'm going to wrap up a PR to fix this, I'll send it accross shortly.

Robert

SirRawlins commented 5 years ago

PR just landed folks. Let me know if you need anything else confirming.

pienkowb commented 5 years ago

@kritik Could you publish the new version (1.0.7) to RubyGems.org? 🙂

kritik commented 5 years ago

done