From 634408363e53942abdd4287d089afbed95a4ee55 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Tue, 26 May 2020 15:35:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E8=8A=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 4 ++++ app/views/repositories/show.json.jbuilder | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 04bf22cf8..431f4eabb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -52,6 +52,10 @@ module ApplicationHelper "avatars" end + def replace_bytes_to_b(size_string) + return size_string.gsub("Bytes", "B").gsub("bytes", "B").gsub("字节", "B") + end + def storage_path File.join(Rails.root, "public", "images", relative_path) end diff --git a/app/views/repositories/show.json.jbuilder b/app/views/repositories/show.json.jbuilder index 6693d966d..0e1e1fb84 100644 --- a/app/views/repositories/show.json.jbuilder +++ b/app/views/repositories/show.json.jbuilder @@ -29,7 +29,7 @@ json.fork_info do end end -json.size number_to_human_size(@result['size'].to_i) +json.size replace_bytes_to_b(number_to_human_size(@result['size'].to_i*1024)) json.ssh_url @result['ssh_url'] json.clone_url @result['clone_url'] json.default_branch @result['default_branch']