diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/invoice.js | 7 | ||||
| -rw-r--r-- | src/lib/utils.js | 9 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/lib/invoice.js b/src/lib/invoice.js index f0c5aad5..983cde2a 100644 --- a/src/lib/invoice.js +++ b/src/lib/invoice.js @@ -29,9 +29,6 @@ export default async ({ cookies, request, url }) => { throw redirect(307, `/${user.username}/request/${request_id}`); } - if (invoice.prompt) { - throw redirect(307, `/invoice/${hash}/tip`); - } else { - throw redirect(307, `/invoice/${hash}`); - } + if (invoice.prompt) throw redirect(307, `/invoice/${hash}/tip`); + else throw redirect(307, `/invoice/${hash}`); }; diff --git a/src/lib/utils.js b/src/lib/utils.js index e6325e9f..bb6b34fa 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -137,8 +137,9 @@ export const login = async (user, cookies) => { let expires = new Date(); expires.setSeconds(expires.getSeconds() + maxAge); - cookies.set('username', user.username, { path: '/', expires }); - cookies.set('token', token, { path: '/', expires }); + let opts = { path: '/', expires } + cookies.set('username', user.username, opts); + cookies.set('token', token, opts); }; export const auth = (cookies) => ({ authorization: `Bearer ${cookies.get('token')}` }); @@ -160,8 +161,8 @@ export const sat = (s) => { return ( '⚡️' + (parseInt(s) > 0 - ? new Intl.NumberFormat('en-US', { maximumFractionDigits: 1 }).format(s / Math.pow(1000, d)) + - ['', 'K', 'M', 'G', 'T', 'P'][d] + ? new Intl.NumberFormat('en-US', { maximumFractionDigits: 2 }).format(s / Math.pow(1000, d)) + + ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z'][d] : 0 ).toString() ); |
