Merge pull request #22178 from overleaf/jpa-file-view-hash-2

[web] migrate file-view to download from history-v1 (via web) 2/2

GitOrigin-RevId: 93172cbbd2d19a55bb27f5b0ca0b494f815a3632
This commit is contained in:
Jakob Ackermann
2024-11-28 09:06:37 +00:00
committed by Copybot
parent ce0d5fd383
commit faff4f1d7e
10 changed files with 46 additions and 97 deletions
@@ -106,8 +106,7 @@ export function findEntityByPath(
export function previewByPath(
folder: Folder,
projectId: string,
path: string,
fileTreeFromHistory: boolean
path: string
): PreviewPath | null {
for (const suffix of [
'',
@@ -125,9 +124,7 @@ export function previewByPath(
if (result?.type === 'fileRef') {
const { name, _id: id, hash } = result.entity
return {
url: fileTreeFromHistory
? `/project/${projectId}/blob/${hash}`
: `/project/${projectId}/file/${id}`,
url: `/project/${projectId}/blob/${hash}?fallback=${id}`,
extension: name.slice(name.lastIndexOf('.') + 1),
}
}