修复: readme匹配修复
This commit is contained in:
parent
29d9410e42
commit
d154f0aecc
|
@ -99,7 +99,7 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/"
|
@path = GiteaService.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/"
|
||||||
interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, file_path_uri, ref: @ref)
|
interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, file_path_uri, ref: @ref)
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
result = interactor.result
|
result = interactor.result
|
||||||
|
|
|
@ -104,23 +104,17 @@ module RepositoriesHelper
|
||||||
# 链接直接跳过不做替换
|
# 链接直接跳过不做替换
|
||||||
next if s_content.starts_with?('http://') || s_content.starts_with?('https://') || s_content.starts_with?('mailto:') || s_content.blank?
|
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 = File.extname(s_content)[1..-1]
|
||||||
repo_regex = /([a-zA-Z0-9_-]{4,15})\/[a-zA-Z0-9_-]+$/
|
if (image_type?(ext) || download_type(ext)) && !ext.blank?
|
||||||
if (image_type?(ext) || download_type(ext)) && !s_content.to_s.end_with?('/')
|
s_content = File.expand_path(s_content, file_path)
|
||||||
if s_content.to_s.scan(repo_regex).size > 0
|
s_content = s_content.split("#{Rails.root}/")[1]
|
||||||
s_content = [base_url, '/', s_content].join
|
# content = content.gsub(s[0], "/#{s_content}")
|
||||||
content = content.gsub(s[0], s_content)
|
s_content = [base_url, "/api/#{owner&.login}/#{repo.identifier}/raw?filepath=#{s_content}&ref=#{ref}"].join
|
||||||
else
|
content = content.gsub(s[0], s_content)
|
||||||
s_content = File.expand_path(s_content, file_path)
|
|
||||||
s_content = s_content.split("#{Rails.root}/")[1]
|
|
||||||
# content = content.gsub(s[0], "/#{s_content}")
|
|
||||||
s_content = [base_url, "/api/#{owner&.login}/#{repo.identifier}/raw?filepath=#{s_content}&ref=#{ref}"].join
|
|
||||||
content = content.gsub(s[0], s_content)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
path = [owner&.login, repo&.identifier, 'tree', ref, file_path].join("/")
|
path = [owner&.login, repo&.identifier, 'tree', ref, file_path].join("/")
|
||||||
s_content = File.expand_path(s_content, path)
|
s_content = File.expand_path(s_content, path)
|
||||||
s_content = s_content.split("#{Rails.root}/")[1]
|
s_content = s_content.split("#{Rails.root}/")[1]
|
||||||
content = content.gsub(s[0], "/#{s_content}")
|
content = content.gsub('('+s[0]+')', '('+"/#{s_content}"+')')
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
next
|
next
|
||||||
|
|
Loading…
Reference in New Issue