Skip to content

Commit 4c9afb8

Browse files
committed
fix: protect UriValidator from nil value
1 parent 7c7dd04 commit 4c9afb8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

app/validators/uri_validator.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def valid?(value, options)
2727
end
2828

2929
def self.before_validation(raw, default_scheme='http://')
30+
return nil if raw.nil?
3031
raw.strip!
3132
return nil if raw.blank?
3233

@@ -57,6 +58,7 @@ def self.before_validation(raw, default_scheme='http://')
5758
def self.after_validation(raw)
5859
# Decodes sharp signs (#) found in URI fragment to keep visual match with
5960
# the user input
61+
return nil if raw.nil?
6062
fragments = raw.split("#")
6163
if (fragments.length == 2)
6264
raw = fragments[0] + '#' + fragments[1].gsub('%23', '#')

0 commit comments

Comments
 (0)