Openstatus
www.openstatus.dev
1import { regions } from "../regions/vercel";
2import type { ParserReturn, Region } from "../types";
3
4export function parseXVercelId(header: string): ParserReturn<Region[]> {
5 const regex = /([a-z]{3}[0-9])+:+/g;
6
7 const arr = header.match(regex);
8 if (!arr || !arr.length) {
9 return { status: "failed", error: new Error("Couldn't parse the header.") };
10 }
11
12 const data = arr.map((r) => {
13 const regionId = r.replace(/:+/, "");
14 return regions[regionId];
15 });
16
17 return { status: "success", data };
18}