lib/string_tools.rb in string_tools-1.2.0 vs lib/string_tools.rb in string_tools-1.3.0

- old
+ new

@@ -224,19 +224,22 @@ node.remove_attribute(attr_name) if node[attr_name].empty? end end class IframeNormalizer + HOSTING_REG = %r{^https?:\/\/(www\.)?(?:(rutube\.ru\/(video|play|embed))| + (youtu((?:be|\.be|be\-nocookie)(?:\/|\.com\/(watch|shorts|embed)))))}x.freeze + def initialize(attributes) @attributes = attributes end def call(env) node = env[:node] return unless node.name == 'iframe' - unless node[:src] =~ %r{^(http|https):?\/\/(www\.)?youtube?\.com\/} + unless node[:src] =~ HOSTING_REG node.unlink return end Sanitize.node!(env[:node], elements: %w(iframe), attributes: {'iframe' => @attributes})