fix: readme image regex error rescued

This commit is contained in:
yystopf 2022-03-28 11:25:13 +08:00
parent 4c69c4d20f
commit a5be4a9502
1 changed files with 34 additions and 30 deletions

View File

@ -59,6 +59,7 @@ module RepositoriesHelper
total_images = ss + ss_src + ss_src2
if total_images.length > 0
total_images.each do |s|
begin
image_title = /\"(.*?)\"/
r_content = s[0]
remove_title = r_content.to_s.scan(image_title)
@ -91,6 +92,9 @@ module RepositoriesHelper
new_r_content = [base_url, "/api/#{owner&.login}/#{repo.identifier}/raw?filepath=#{path_current}/#{path_last}&ref=#{ref}"].join
end
content = content.gsub(/src=\"#{r_content}\"/, "src=\"#{new_r_content}\"").gsub(/src='#{r_content}'/, "src=\"#{new_r_content}\"")
rescue
next
end
end
end