class Qiita::Markdown::Transformers::FilterIframe
Constants
- HOST_WHITE_LIST
- URL_WHITE_LIST
Public Class Methods
Source
# File lib/qiita/markdown/transformers/filter_iframe.rb, line 17 def self.call(**args) new(**args).transform end
Source
# File lib/qiita/markdown/transformers/filter_iframe.rb, line 21 def initialize(env) @env = env end
Public Instance Methods
Source
# File lib/qiita/markdown/transformers/filter_iframe.rb, line 25 def transform if name == "iframe" if URL_WHITE_LIST.include?(node["src"]) || HOST_WHITE_LIST.include?(host_of(node["src"])) node["width"] = "100%" node.children.unlink else node.unlink end end end
Private Instance Methods
Source
# File lib/qiita/markdown/transformers/filter_iframe.rb, line 46 def host_of(url) if url scheme = URI.parse(url).scheme Addressable::URI.parse(url).host if ["http", "https", nil].include? scheme end rescue Addressable::URI::InvalidURIError, URI::InvalidURIError nil end
Source
# File lib/qiita/markdown/transformers/filter_iframe.rb, line 38 def name @env[:node_name] end
Source
# File lib/qiita/markdown/transformers/filter_iframe.rb, line 42 def node @env[:node] end