Skip to content

Commit

Permalink
Fixed a failing spec when validation nil
Browse files Browse the repository at this point in the history
A recent change which added URI.escape(value) meant that specs were failing when validating 'nil'.

We now only escape if it's a string, meaning all specs now pass again.
  • Loading branch information
SirRawlins committed Mar 13, 2019
1 parent 8c37c2b commit a155726
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/validate_url.rb
Expand Up @@ -20,7 +20,8 @@ def initialize(options)
def validate_each(record, attribute, value)
schemes = [*options.fetch(:schemes)].map(&:to_s)
begin
uri = URI.parse(URI.escape(value))
escaped_uri = value ? URI.escape(value) : nil
uri = URI.parse(escaped_uri)
host = uri && uri.host
scheme = uri && uri.scheme

Expand Down

0 comments on commit a155726

Please sign in to comment.