mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Ignore accidental spaces around whitelabel URL
This commit is contained in:
@@ -460,6 +460,7 @@ class Enterprise < ApplicationRecord
|
||||
|
||||
return if white_label_logo_link.blank?
|
||||
|
||||
white_label_logo_link.strip!
|
||||
uri = URI(white_label_logo_link)
|
||||
self.white_label_logo_link = "http://#{white_label_logo_link}" if uri.scheme.nil?
|
||||
rescue URI::InvalidURIError
|
||||
|
||||
@@ -332,6 +332,12 @@ describe Enterprise do
|
||||
expect(e.white_label_logo_link).to eq "http://www.example.com"
|
||||
end
|
||||
|
||||
it "ignores whitespace around the URL form copying and pasting" do
|
||||
e = build(:enterprise, white_label_logo_link: ' www.example.com ')
|
||||
expect(e).to be_valid
|
||||
expect(e.white_label_logo_link).to eq "http://www.example.com"
|
||||
end
|
||||
|
||||
it "does not validate if URL is invalid and can't be infered" do
|
||||
e = build(:enterprise, white_label_logo_link: 'with spaces')
|
||||
expect(e).to be_invalid
|
||||
|
||||
Reference in New Issue
Block a user