add news feed (#99)

* add news feed

* Prettified Code!

Co-authored-by: gingervitis <gingervitis@users.noreply.github.com>
This commit is contained in:
gingervitis
2021-04-03 21:25:21 -07:00
committed by GitHub
parent 3fc7619367
commit 2c86fa34fd
5 changed files with 146 additions and 17 deletions

View File

@ -116,9 +116,9 @@ export async function fetchData(url: string, options?: FetchOptions) {
return {};
}
export async function getGithubRelease() {
export async function fetchExternalData(url: string) {
try {
const response = await fetch(GITHUB_RELEASE_URL);
const response = await fetch(url);
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
@ -131,6 +131,10 @@ export async function getGithubRelease() {
return {};
}
export async function getGithubRelease() {
return fetchExternalData(GITHUB_RELEASE_URL);
}
// Stolen from https://gist.github.com/prenagha/98bbb03e27163bc2f5e4
const VPAT = /^\d+(\.\d+){0,2}$/;
function upToDate(local, remote) {