diff --git a/index.js b/index.js index 8a3cbfc..cba7f28 100644 --- a/index.js +++ b/index.js @@ -164,6 +164,23 @@ router.post('/generate', async ctx => { ctx.body = key }) +router.get('/download/:key', async ctx => { + const key = ctx.cookies.get('key') + if (!key) { + await next() + return + } + + const info = ctx.keys.get(key) + + if (!info || !info.file) { + await next() + return + } + + ctx.redirect('/' + encodeURIComponent(info.file.name)); +}) + async function downloadFile (ctx, next) { const key = ctx.cookies.get('key') if (!key) { diff --git a/static/download.html b/static/download.html index cd989e1..0278643 100644 --- a/static/download.html +++ b/static/download.html @@ -78,9 +78,6 @@ function pollFile () { downloads.style.display = 'none' } var urls = data.urls && data.urls.length > 0 ? data.urls : null - if (data.file || urls) { - } else { - } if (data.file) { downloads.style.display = 'block' downloadlink.textContent = data.file.name