From aef425ef6995c345032c8a63dfcd749ce369714f Mon Sep 17 00:00:00 2001 From: eladlachmi <110764839+eladlachmi@users.noreply.github.com> Date: Tue, 18 Oct 2022 13:16:58 +0300 Subject: [PATCH] README.md file viewer not displaying content according to file extension (#4380) --- .../pages/repositories/repository/objects.jsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/webui/src/pages/repositories/repository/objects.jsx b/webui/src/pages/repositories/repository/objects.jsx index 886d4843c20..76935a0475c 100644 --- a/webui/src/pages/repositories/repository/objects.jsx +++ b/webui/src/pages/repositories/repository/objects.jsx @@ -297,20 +297,22 @@ const TreeContainer = ({ } const ReadmeContainer = ({repo, reference, path='', refreshDep=''}) => { + let readmePath = ''; + + if (path) { + readmePath = path.endsWith('/') ? `${path}${README_FILE_NAME}` : `${path}/${README_FILE_NAME}`; + } else { + readmePath = README_FILE_NAME; + } const {response, error, loading} = useAPI(async () => { - if (path) { - path = path.endsWith('/') ? `${path}${README_FILE_NAME}` : `${path}/${README_FILE_NAME}`; - } else { - path = README_FILE_NAME; - } - return await objects.getWithHeaders(repo.id, reference.id, path); + return await objects.getWithHeaders(repo.id, reference.id, readmePath); }, [path, refreshDep]); if (loading || error) { return <>; } - const fileExtension = getFileExtension(path); + const fileExtension = getFileExtension(readmePath); const contentType = getContentType(response?.headers); return (