From 5b97f79569a48e6bdf3555b967d2f62aef145112 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Thu, 23 Nov 2023 00:57:24 +0100 Subject: [PATCH] DEV: Replace `starts_with?` with `start_with?` in `HtmlToMarkdown` (#24521) This allows us to use that class without loading Rails, e.g. in imports (converters). --- lib/html_to_markdown.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/html_to_markdown.rb b/lib/html_to_markdown.rb index 67626fd76e7..b0415718603 100644 --- a/lib/html_to_markdown.rb +++ b/lib/html_to_markdown.rb @@ -157,7 +157,7 @@ class HtmlToMarkdown end def visit_a(node) - if node["href"].present? && node["href"].starts_with?(*allowed_hrefs) + if node["href"].present? && node["href"].start_with?(*allowed_hrefs) "[#{traverse(node)}](#{node["href"]})" else traverse(node) @@ -169,9 +169,9 @@ class HtmlToMarkdown if @opts[:keep_img_tags] node.to_html - elsif @opts[:keep_cid_imgs] && node["src"].starts_with?("cid:") + elsif @opts[:keep_cid_imgs] && node["src"].start_with?("cid:") node.to_html - elsif node["src"].starts_with?(*ALLOWED_IMG_SRCS) + elsif node["src"].start_with?(*ALLOWED_IMG_SRCS) title = node["alt"].presence || node["title"].presence width = node["width"].to_i height = node["height"].to_i