Skip to content

Instantly share code, notes, and snippets.

@obfusk
Last active August 12, 2023 23:30
Show Gist options
  • Save obfusk/fc5e7e4e129c0e4192d8fd6f7aa90f14 to your computer and use it in GitHub Desktop.
Save obfusk/fc5e7e4e129c0e4192d8fd6f7aa90f14 to your computer and use it in GitHub Desktop.
jsonata last-modified
const jsonata = require("jsonata");
const axios = require("axios");
const jsonPath = "$toMillis(`last-modified`, '[FNn,-3], [D] [MNn,-3] [Y] [H]:[m]:[s] GMT') > $millis() - 1000 * 60 * 60 * 24 * 7";
const expectedValue = "true";
let res = await axios.request({url: "https://f-droid.org/repo/index-v1.jar", method: "HEAD"});
headers = res.headers;
let expression = jsonata(jsonPath);
let result = await expression.evaluate(headers);
if (result.toString() === expectedValue) {
console.log("yay!");
} else {
throw new Error("oops");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment