fix: get file extname

This commit is contained in:
yystopf 2021-07-23 14:47:05 +08:00
parent f5e07ab3ec
commit f334864f1b
2 changed files with 2 additions and 2 deletions

View File

@ -81,7 +81,7 @@ module RepositoriesHelper
content = Gitea::Repository::Entries::GetService.call(owner, repo.identifier, entry['path'], ref: ref)['content']
readme_render_decode64_content(content, path)
else
file_type = entry['name'].to_s.split(".").last
file_type = File.extname(entry['name'].to_s)[1..-1]
if download_type(file_type)
return entry['content'].nil? ? Gitea::Repository::Entries::GetService.call(owner, repo.identifier, entry['path'], ref: ref)['content'] : entry['content']
end

View File

@ -1,6 +1,6 @@
if @project.forge?
file_name = entry['name']
file_type = file_name.to_s.split(".").last
file_type = File.extname(file_name.to_s)[1..-1]
direct_download = download_type(file_type)
image_type = image_type?(file_type)
json.name file_name