From d471ad08c6d5c06ba244fbd0913dacb3c6c43999 Mon Sep 17 00:00:00 2001 From: Benjamin Elijah Griffin Date: Tue, 1 Aug 2017 23:37:28 -0700 Subject: [PATCH] Website RE validator without a 10 char limit on TLD. --- app/models/user_profile.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb index 8ce2d186d4a..300978f1c8a 100644 --- a/app/models/user_profile.rb +++ b/app/models/user_profile.rb @@ -1,7 +1,10 @@ class UserProfile < ActiveRecord::Base belongs_to :user, inverse_of: :user_profile - WEBSITE_REGEXP = /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,10}(([0-9]{1,5})?\/.*)?$)/ix + # This is not very picky about most DNS labels (the bits between the + # periods), but isn't taking much guff from the TLD. No leading + # digit, and no hyphens unless IDN. + WEBSITE_REGEXP = /(^$)|((^(http|https):\/\/)?([a-z0-9][a-z0-9-]*\.)+([a-z][a-z0-9]+|xn--[a-z0-9-]+)(\/.*)?$)/ix validates :bio_raw, length: { maximum: 3000 } validates :website, format: { with: WEBSITE_REGEXP }, allow_blank: true, if: Proc.new { |c| c.new_record? || c.website_changed? }