Class: Qiita::Markdown::Filters::ExternalLink
- Inherits:
-
HTML::Pipeline::Filter
- Object
- HTML::Pipeline::Filter
- Qiita::Markdown::Filters::ExternalLink
- Defined in:
- lib/qiita/markdown/filters/external_link.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/qiita/markdown/filters/external_link.rb', line 7 def call doc.search("a").each do |anchor| next unless anchor["href"] href = anchor["href"].strip href_host = host_of(href) next unless href_host if href_host != hostname anchor["rel"] = "nofollow noopener" anchor["target"] = "_blank" end end doc end |
#validate ⇒ Object
24 25 26 |
# File 'lib/qiita/markdown/filters/external_link.rb', line 24 def validate needs :hostname end |