Sha256: 2b1c91e33cf725c75b7b64e571f3678d7d93f0e8b725544bd987b2e468841b58
Contents?: true
Size: 970 Bytes
Versions: 9
Compression:
Stored size: 970 Bytes
Contents
module SmartRspec module Support module Regexes @@uri_regexes = { protocol: /((ht|f)tp[s]?)/i, uri: %r{^( (((ht|f)tp[s]?://)|([a-z0-9]+\.))+ (?<!@) ([a-z0-9\_\-]+) (\.[a-z]+)+ ([\?/\:][a-z0-9_=%&@\?\./\-\:\#\(\)]+)? /? )$}ix } def build_regex(type, *args) case type.to_sym when :email then /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i when :image then build_img_regex(args) else @@uri_regexes[type] end end private_class_method def build_img_regex(exts = []) exts = [exts].flatten if exts.nil? || exts.empty? exts = %w(jpg jpeg png gif) elsif exts.include?(:jpg) && !exts.include?(:jpeg) exts.push :jpeg end %r{(^http{1}[s]?://([w]{3}\.)?.+\.(#{exts.join('|')})(\?.+)?$)}i end end end end
Version data entries
9 entries across 9 versions & 1 rubygems