Skip to content

Commit 265ed3d

Browse files
committed
Added temp fix to replay.
1 parent fa00f47 commit 265ed3d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Replay/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ function a(){
399399
_editor.setMode('view');
400400
IndexedDBOperation.do({operation: 'addReplayToStorage', data: _editor.getText()});
401401
GitHubApi.fetch('search/repositories?q=topic:AI-Tournaments+topic:AI-Tournaments-Replay+topic:'+_replayData.body.arena.full_name.replace('/','--')).then(response => response.json()).then(response => {
402-
document.getElementById('default-option').value = _replayData.header.defaultReplay;
402+
const officialUrl = 'https://ai-tournaments.github.io/'; // TODO: 👇 Either only allow absolute URL:s or calculate arena origin.
403+
document.getElementById('default-option').value = (_replayData.header.defaultReplay[0]==='/'?officialUrl:'')+_replayData.header.defaultReplay;
403404
response.items.forEach(repo => {
404405
if(repo.has_pages){
405406
let cssStar = getComputedStyle(document.documentElement).getPropertyValue('--github-stars').trim();
@@ -418,8 +419,8 @@ function a(){
418419
options.sort(function(a, b){
419420
if(b.id === 'default-option'){return 1;}
420421

421-
let aOfficial = a.value.startsWith('https://ai-tournaments.github.io/');
422-
let bOfficial = b.value.startsWith('https://ai-tournaments.github.io/');
422+
let aOfficial = a.value.startsWith(officialUrl);
423+
let bOfficial = b.value.startsWith(officialUrl);
423424
if(aOfficial ? !bOfficial : bOfficial){return 1;}
424425

425426
if(parseFloat(a.dataset.stars) < parseFloat(b.dataset.stars)){return -1;}

0 commit comments

Comments
 (0)