HistoryURLHelper.js 798 B

123456789101112131415161718192021
  1. // Pass settings to enable consistent unit tests from .js and .mjs modules
  2. function projectHistoryURLWithFilestoreFallback(
  3. Settings,
  4. projectId,
  5. historyId,
  6. fileRef,
  7. origin
  8. ) {
  9. const filestoreURL = `${Settings.apis.filestore.url}/project/${projectId}/file/${fileRef._id}?from=${origin}`
  10. // TODO: When this file is converted to ES modules we will be able to use Features.hasFeature('project-history-blobs'). Currently we can't stub the feature return value in tests.
  11. if (fileRef.hash && Settings.filestoreMigrationLevel >= 1) {
  12. return {
  13. url: `${Settings.apis.project_history.url}/project/${historyId}/blob/${fileRef.hash}`,
  14. fallbackURL: filestoreURL,
  15. }
  16. } else {
  17. return { url: filestoreURL }
  18. }
  19. }
  20. module.exports = { projectHistoryURLWithFilestoreFallback }