fixed md中图片处理包含中文名称,tip

This commit is contained in:
xxq250 2025-09-01 10:52:41 +08:00
parent 7d67defa24
commit e2ff617715
1 changed files with 10 additions and 2 deletions

View File

@ -157,6 +157,7 @@ module RepositoriesHelper
next if s_content.starts_with?('http://') || s_content.starts_with?('https://') || s_content.starts_with?('mailto:') || s_content.blank?
ext = File.extname(s_content)[1..-1]
ext = ext.split("?")[0] if ext.include?("?")
ext = ext.gsub(/ \".*\"/, "") if ext.include?(" ")
if (image_type?(ext) || download_type(ext)) && !ext.blank?
s_content = s_content.starts_with?("/") ? s_content[1..-1] : s_content[0..-1]
s_content = File.expand_path(s_content, file_path)
@ -203,8 +204,15 @@ module RepositoriesHelper
content = content.gsub("href=\"#{s[0]}\"", "href=\"#{s_content}\"")
when 'ss_href_1'
content = content.gsub("href=\'#{s[0]}\'", "href=\'#{s_content}\'")
else
content = content.gsub("(#{s[0]})", "(#{s_content})")
else
## md中图片处理包含中文名称tip
if s[0].to_s.include?(" ")
s1 = s[0].to_s.split(" ")
s2 = s1[1] if s1.size >1
content = content.gsub("(#{s1} #{s2})", "(#{s_content} #{s2})")
else
content = content.gsub("(#{s[0]})", "(#{s_content})")
end
end
end
rescue