From 808a9b584723e3e6142895afee7056b85feaadd5 Mon Sep 17 00:00:00 2001 From: Atefeh Mohseni Ejiyeh Date: Fri, 4 Apr 2025 00:48:14 +0000 Subject: [PATCH] fix: [CODE-3459] Raw URL for LFS files in non standalone (#3627) * ui lints prettier * ui lint fix * ui: fix raw url on lfs files --- .../FileContent/FileContent.tsx | 29 +++++-------------- web/src/utils/FileUtils.ts | 4 ++- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/web/src/pages/Repository/RepositoryContent/FileContent/FileContent.tsx b/web/src/pages/Repository/RepositoryContent/FileContent/FileContent.tsx index c6e305cb5..ad81d2369 100644 --- a/web/src/pages/Repository/RepositoryContent/FileContent/FileContent.tsx +++ b/web/src/pages/Repository/RepositoryContent/FileContent/FileContent.tsx @@ -61,7 +61,6 @@ import { useAppContext } from 'AppContext' import { LatestCommitForFile } from 'components/LatestCommit/LatestCommit' import { useCommitModal } from 'components/CommitModalButton/CommitModalButton' import { useStrings } from 'framework/strings' -import { getConfig } from 'services/config' import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton' import { PlainButton } from 'components/PlainButton/PlainButton' import { CommitsView } from 'components/CommitsView/CommitsView' @@ -210,10 +209,6 @@ export function FileContent({ } } - const fullRawURL = standalone - ? `${window.location.origin}${rawURL.replace(/^\/code/, '')}` - : `${window.location.origin}${getConfig(rawURL)}`.replace('//', '/') - return ( { - const url = standalone - ? rawURL.replace(/^\/code/, '') - : getConfig(rawURL).replace('//', '/') + const url = rawURL window.open(url, '_blank') } }, @@ -427,9 +420,7 @@ export function FileContent({ {filename} @@ -437,9 +428,7 @@ export function FileContent({ {filename} @@ -488,7 +473,7 @@ export function FileContent({ diff --git a/web/src/utils/FileUtils.ts b/web/src/utils/FileUtils.ts index 5b803ff50..3aa82b55f 100644 --- a/web/src/utils/FileUtils.ts +++ b/web/src/utils/FileUtils.ts @@ -18,6 +18,7 @@ import { useMemo } from 'react' import { pdfjs } from 'react-pdf' import { useAppContext } from 'AppContext' import type { RepoFileContent } from 'services/code' +import { getConfig } from 'services/config' import type { GitInfoProps } from './GitUtils' // TODO: Configure this to use a local worker/webpack loader @@ -105,7 +106,8 @@ export function useFileContentViewerDecision({ resourceData?.lfs_object_size > MAX_VIEWABLE_FILE_SIZE : resourceData?.data_size && resourceData?.size && resourceData?.data_size !== resourceData?.size) || false - const rawURL = `/code/api/v1/repos/${repoMetadata?.path}/+/raw/${resourcePath}?routingId=${routingId}&git_ref=${gitRef}` + const base = getConfig('code/api/v1') + const rawURL = `${base}/repos/${repoMetadata?.path}/+/raw/${resourcePath}?routingId=${routingId}&git_ref=${gitRef}` return { category,