reportArtifactLinks.js 740 B

12345678910111213141516171819202122
  1. function reportArtifactUrl(item = {}, kind) {
  2. if (kind === 'background') return item.backgroundReportUrl || ''
  3. if (kind === 'professional') return item.professionalReportUrl || ''
  4. if (kind === 'public') return item.publicReportUrl || item.fileUrl || ''
  5. return ''
  6. }
  7. function reportArtifactLinks(item = {}) {
  8. return {
  9. background: reportArtifactUrl(item, 'background'),
  10. professional: reportArtifactUrl(item, 'professional'),
  11. public: reportArtifactUrl(item, 'public')
  12. }
  13. }
  14. function reportArtifactDownloadUrl(url) {
  15. if (!url) return ''
  16. const separator = url.indexOf('?') >= 0 ? '&' : '?'
  17. return `${url}${separator}_download=${Date.now()}`
  18. }
  19. module.exports = { reportArtifactUrl, reportArtifactLinks, reportArtifactDownloadUrl }