Skip to content

Commit

Permalink
fix redirect loop for latest link
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrybyk committed Feb 8, 2024
1 parent df43114 commit 029fa65
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40730,7 +40730,7 @@ var external_path_ = __nccwpck_require__(1017);
var promises_ = __nccwpck_require__(3292);
;// CONCATENATED MODULE: ./src/report_latest.ts
// autogenerated
const latestReport = Buffer.from('PCEtLSByZXBvcnQtYWN0aW9uIC0tPgo8IWRvY3R5cGUgaHRtbD4KPGh0bWwgbGFuZz0iZW4iPgogIDxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiIC8+CiAgICA8dGl0bGU+UmVkaXJlY3QgdG8gbGF0ZXN0PC90aXRsZT4KICA8L2hlYWQ+CgogIDxib2R5PgogICAgPGgxPlJlZGlyZWN0aW5nIHRvIHRoZSBsYXRlc3QgcnVuLi4uPC9oMT4KCiAgICA8c2NyaXB0PgogICAgICBmZXRjaChgLi9sYXN0UnVuLmpzb24/dD0ke0RhdGUubm93KCl9YCkKICAgICAgICAudGhlbigocmVzcG9uc2UpID0+IHJlc3BvbnNlLm9rICYmIHJlc3BvbnNlLmpzb24oKSkKICAgICAgICAudGhlbigoanNvbikgPT4gewogICAgICAgICAgaWYgKCFqc29uKSB7CiAgICAgICAgICAgIHJldHVybgogICAgICAgICAgfQoKICAgICAgICAgIHdpbmRvdy5sb2NhdGlvbi5yZXBsYWNlKHdpbmRvdy5sb2NhdGlvbi5wYXRobmFtZS5yZXBsYWNlKCdsYXRlc3QuaHRtbCcsIGAke2pzb24ucnVuSWR9XyR7anNvbi5ydW5UaW1lc3RhbXB9YCkpCiAgICAgICAgfSkKICAgIDwvc2NyaXB0PgogIDwvYm9keT4KPC9odG1sPgo=', 'base64');
const latestReport = Buffer.from('PCEtLSByZXBvcnQtYWN0aW9uIC0tPgo8IWRvY3R5cGUgaHRtbD4KPGh0bWwgbGFuZz0iZW4iPgogIDxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiIC8+CiAgICA8dGl0bGU+UmVkaXJlY3QgdG8gbGF0ZXN0PC90aXRsZT4KICA8L2hlYWQ+CgogIDxib2R5PgogICAgPGgxPlJlZGlyZWN0aW5nIHRvIHRoZSBsYXRlc3QgcnVuLi4uPC9oMT4KCiAgICA8c2NyaXB0PgogICAgICBmZXRjaChgLi9sYXN0UnVuLmpzb24/dD0ke0RhdGUubm93KCl9YCkKICAgICAgICAudGhlbigocmVzcG9uc2UpID0+IHJlc3BvbnNlLm9rICYmIHJlc3BvbnNlLmpzb24oKSkKICAgICAgICAudGhlbigoanNvbikgPT4gewogICAgICAgICAgaWYgKCFqc29uKSB7CiAgICAgICAgICAgIHJldHVybgogICAgICAgICAgfQoKICAgICAgICAgIGNvbnN0IGVuZGluZyA9IHdpbmRvdy5sb2NhdGlvbi5wYXRobmFtZS5lbmRzV2l0aCgnbGF0ZXN0Lmh0bWwnKQogICAgICAgICAgICA/ICdsYXRlc3QuaHRtbCcKICAgICAgICAgICAgOiB3aW5kb3cubG9jYXRpb24ucGF0aG5hbWUuZW5kc1dpdGgoJ2xhdGVzdCcpCiAgICAgICAgICAgICAgPyAnbGF0ZXN0JwogICAgICAgICAgICAgIDogbnVsbAogICAgICAgICAgaWYgKGVuZGluZykgewogICAgICAgICAgICB3aW5kb3cubG9jYXRpb24ucmVwbGFjZSh3aW5kb3cubG9jYXRpb24ucGF0aG5hbWUucmVwbGFjZShlbmRpbmcsIGAke2pzb24ucnVuSWR9XyR7anNvbi5ydW5UaW1lc3RhbXB9YCkpCiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb25zb2xlLmVycm9yKCdzb21ldGhpbmcgd2VudCB3cm9uZycpCiAgICAgICAgICB9CiAgICAgICAgfSkKICAgIDwvc2NyaXB0PgogIDwvYm9keT4KPC9odG1sPgo=', 'base64');

;// CONCATENATED MODULE: ./src/writeLatest.ts

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "allure-report-branch-js-action",
"version": "1.4.0",
"version": "1.4.1",
"description": "Allure Report with history per branch",
"main": "index.js",
"type": "module",
Expand Down
11 changes: 10 additions & 1 deletion reports/html/latest.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ <h1>Redirecting to the latest run...</h1>
return
}

window.location.replace(window.location.pathname.replace('latest.html', `${json.runId}_${json.runTimestamp}`))
const ending = window.location.pathname.endsWith('latest.html')
? 'latest.html'
: window.location.pathname.endsWith('latest')
? 'latest'
: null
if (ending) {
window.location.replace(window.location.pathname.replace(ending, `${json.runId}_${json.runTimestamp}`))
} else {
console.error('something went wrong')
}
})
</script>
</body>
Expand Down

0 comments on commit 029fa65

Please sign in to comment.