diff --git a/app/models/routed_query.rb b/app/models/routed_query.rb index c3a440569b..2cdad89be9 100644 --- a/app/models/routed_query.rb +++ b/app/models/routed_query.rb @@ -11,7 +11,7 @@ class RoutedQuery < ApplicationRecord validates_uniqueness_of :description, scope: :affiliate_id validates :affiliate, presence: true - validates_format_of :url, with: URI.regexp + validates_url :url validate :keywords_cannot_be_blank diff --git a/spec/models/routed_query_spec.rb b/spec/models/routed_query_spec.rb index 824294cbae..43bd3dd540 100644 --- a/spec/models/routed_query_spec.rb +++ b/spec/models/routed_query_spec.rb @@ -32,6 +32,7 @@ it { is_expected.to validate_presence_of :affiliate } it { is_expected.to allow_value('http://www.foo.com').for(:url) } it { is_expected.not_to allow_value('www.foo.com').for(:url) } + it { is_expected.not_to allow_value('data:text/;&Tab.base64').for(:url) } it 'creates a new instance given valid attributes' do affiliate.routed_queries.create!(valid_attributes)