app/validators/url_validator.rb in landable-1.13.1 vs app/validators/url_validator.rb in landable-1.13.2
- old
+ new
@@ -1,13 +1,10 @@
class UrlValidator < ActiveModel::EachValidator
-
def validate_each(record, attribute, value)
valid = begin
- value =~ /^[a-z]+\:\/\// or value =~ /^\//
+ value =~ %r{^[a-z]+\:\/\/} || value =~ %r{^\/}
end
+ return if valid
- unless valid
- record.errors[attribute] << ("Invalid URL! Make sure it starts with http:// or /")
- end
+ record.errors[attribute] << ('Invalid URL! Make sure it starts with http:// or /')
end
-
-end
\ No newline at end of file
+end