JS: Some fixes and address review comments

This commit is contained in:
Asger Feldthaus
2020-11-02 10:46:30 +00:00
parent 8a3fba05e9
commit 790526b529
2 changed files with 66 additions and 52 deletions

View File

@@ -1,6 +1,6 @@
import dateFns from 'date-fns';
import dateFnsFp from 'date-fns/fp';
import dateFnsUtc from 'date-fns/utc';
import dateFnsEsm from 'date-fns/esm';
import moment from 'moment';
function main() {
@@ -8,7 +8,7 @@ function main() {
let taint = decodeURIComponent(window.location.hash.substring(1));
document.body.innerHTML = `Time is ${dateFns.format(time, taint)}`; // NOT OK
document.body.innerHTML = `Time is ${dateFnsUtc.format(time, taint)}`; // NOT OK
document.body.innerHTML = `Time is ${dateFnsEsm.format(time, taint)}`; // NOT OK
document.body.innerHTML = `Time is ${dateFnsFp.format(taint)(time)}`; // NOT OK
document.body.innerHTML = `Time is ${dateFns.format(taint, time)}`; // OK - time arg is safe
document.body.innerHTML = `Time is ${dateFnsFp.format(time)(taint)}`; // OK - time arg is safe