mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Regex ajust
This commit is contained in:
@@ -80,7 +80,7 @@ class Enterprise < ActiveRecord::Base
|
||||
before_validation :set_unused_address_fields
|
||||
after_validation :geocode_address
|
||||
|
||||
validates :instagram, format: /\A@[a-zA-Z0-9._]{1,30}\z/, :allow_blank => true
|
||||
validates :instagram, format: /\A@[a-zA-Z0-9._]{1,30}\z/, allow_blank: true
|
||||
|
||||
after_touch :touch_distributors
|
||||
after_create :set_default_contact
|
||||
@@ -333,7 +333,8 @@ class Enterprise < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def instagram=(value)
|
||||
write_attribute(:instagram, value.try(:gsub, %r{\Ahttps?://(?:www.)?instagram.com/([a-zA-Z0-9._]{1,30})/?\z}, '@\1'))
|
||||
regex = %r{\A(?:https?://)?(?:www\.)?instagram\.com/([a-zA-Z0-9._]{1,30})/?\z}
|
||||
write_attribute(:instagram, value.try(:gsub, regex, '@\1'))
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
Reference in New Issue
Block a user