Files
overleaf-cep/services/web/app/src/Features/History/HistoryURLHelper.js
T
Jakob Ackermann b9a56afe4c Merge pull request #22239 from overleaf/jpa-file-url-helper
[web] add helper for getting file URL from history w/ filestore fallback

GitOrigin-RevId: d77e6f1565fab407e1004a02c4bfdfe03a0214d7
2024-12-02 09:05:26 +00:00

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 }