Skip to content

Commit

Permalink
Query string redirect in migration helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kognise committed Mar 10, 2023
1 parent 86b8d6b commit 93830cc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions migration-helper.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
<body>
<p>This is a hidden page for migrating old Sprig games to the new Sprig account system. You probably won't find anything here :)</p>

<form method='post' id='form'>
<input type='hidden' id='puzzle-lab' name='puzzle-lab' value=''>
</form>

<script>
const urlAllowed = (url) => {
const parsed = new URL(url)
Expand Down Expand Up @@ -47,9 +43,9 @@

if (params.has('redirect')) {
if (!urlAllowed(params.get('redirect'))) throw new Error('Disallowed redirect URL')
document.getElementById('form').action = params.get('redirect')
document.getElementById('puzzle-lab').value = window.localStorage.getItem('puzzle-lab') || ''
document.getElementById('form').submit()
const parsed = new URL(params.get('redirect'))
parsed.searchParams.set('puzzleLab', window.localStorage.getItem('puzzle-lab') || '')
window.location.replace(parsed.toString())
} else {
sendToParent()
}
Expand Down

0 comments on commit 93830cc

Please sign in to comment.