From f334864f1bd06cc59691695fa893c4b344fa19d7 Mon Sep 17 00:00:00 2001 From: yystopf Date: Fri, 23 Jul 2021 14:47:05 +0800 Subject: [PATCH] fix: get file extname --- app/helpers/repositories_helper.rb | 2 +- app/views/repositories/_simple_entry.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index f5e76f4e0..a7218810b 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -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 diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index 7d41bbd23..6c2088755 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -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