1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { fetch } from "https://esm.town/v/std/fetch";
export default async function(request: Request): Promise<Response> {
const cheerio = await import("https://esm.sh/cheerio@1.0.0-rc.12");
const response = await fetch("https://releases.1password.com/linux/beta/");
const body = await response.text();
const $ = cheerio.load(body);
const heading = $(".c-page-details div").first().text();
const matchVersion = /^Updated to ([\d.-]+)/.exec(heading);
if (!matchVersion) {
throw new Error("Could not extract version from page");
}
const version = matchVersion[1];
return new Response(JSON.stringify({ version }));
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 15, 2024