Permalink
Browse files

Made protocol not required, added IP support, username and password a…

…nd enhancements.
  • Loading branch information...
1 parent 60c7b91 commit 3f6f6514e461ca367b6593bbabc2386fa1991560 @elado elado committed Jul 4, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/validators/url_format_validator.rb
@@ -4,7 +4,7 @@ def validate_each(record, attribute, value)
end
def self.valid_url?(value)
- value =~ /^(?:https?|ftp):\/\/([^\s\.]+\.)+[a-z]{2,}(?:\/|$)/i
+ value =~ /^((?:https?|ftp):\/\/)?(?:[^:]*:[^@]*@)?(?:(?:[^\s\.:@%#\?]+\.)+[a-z]{2,}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d{1,2}))(?:\/|$)/i
end
end

0 comments on commit 3f6f651

Please sign in to comment.