mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-07 08:09:01 +02:00
b9a56afe4c
[web] add helper for getting file URL from history w/ filestore fallback GitOrigin-RevId: d77e6f1565fab407e1004a02c4bfdfe03a0214d7
20 lines
551 B
JavaScript
20 lines
551 B
JavaScript
// Pass settings to enable consistent unit tests from .js and .mjs modules
|
|
function projectHistoryURLWithFilestoreFallback(
|
|
Settings,
|
|
projectId,
|
|
historyId,
|
|
fileRef
|
|
) {
|
|
const filestoreURL = `${Settings.apis.filestore.url}/project/${projectId}/file/${fileRef._id}`
|
|
if (fileRef.hash) {
|
|
return {
|
|
url: `${Settings.apis.project_history.url}/project/${historyId}/blob/${fileRef.hash}`,
|
|
fallbackURL: filestoreURL,
|
|
}
|
|
} else {
|
|
return { url: filestoreURL }
|
|
}
|
|
}
|
|
|
|
module.exports = { projectHistoryURLWithFilestoreFallback }
|