diff --git a/lib/faker/default/avatar.rb b/lib/faker/default/avatar.rb index 2a8073ad58..f79e13d0e1 100644 --- a/lib/faker/default/avatar.rb +++ b/lib/faker/default/avatar.rb @@ -37,7 +37,7 @@ class << self # # @faker.version 1.4.3 def image(slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil) - raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/ + raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /\A[0-9]+x[0-9]+\z/ raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format) slug ||= Faker::Lorem.words.join diff --git a/lib/faker/default/lorem_flickr.rb b/lib/faker/default/lorem_flickr.rb index 5f0f1f041b..2bb85750e2 100644 --- a/lib/faker/default/lorem_flickr.rb +++ b/lib/faker/default/lorem_flickr.rb @@ -96,7 +96,7 @@ def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_ private def build_url(size, format, search_terms, match_all) - raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/ + raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /\A[0-9]+x[0-9]+\z/ url_parts = ['https://loremflickr.com'] url_parts << format diff --git a/lib/faker/default/placeholdit.rb b/lib/faker/default/placeholdit.rb index 8276412abe..28eb6c84e9 100644 --- a/lib/faker/default/placeholdit.rb +++ b/lib/faker/default/placeholdit.rb @@ -30,7 +30,7 @@ def image(size: '300x300', format: 'png', background_color: nil, text_color: nil background_color = generate_color if background_color == :random text_color = generate_color if text_color == :random - raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/ + raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /\A[0-9]+x[0-9]+\z$/ raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format) raise ArgumentError, "background_color must be a hex value without '#'" unless background_color.nil? || background_color =~ /((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/ raise ArgumentError, "text_color must be a hex value without '#'" unless text_color.nil? || text_color =~ /((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/