Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Created August 10, 2023 13:30
Show Gist options
  • Save juliandescottes/8f356a5bb4c9f06e163b686ca9c42ffa to your computer and use it in GitHub Desktop.
Save juliandescottes/8f356a5bb4c9f06e163b686ca9c42ffa to your computer and use it in GitHub Desktop.
function matchURLPattern(pattern, input) {
return pattern.test(input);
}
function parseURLPattern(patternObj) {
if (patternObj.type === "string") {
return new URLPattern(patternObj.pattern);
} else {
delete patternObj.type;
return new URLPattern(patternObj);
}
}
function ok(cond, message) {
if (cond) {
console.log("SUCCESS: " + message);
} else {
console.error("FAILED: " + message);
}
}
function equal(v1, v2, message) {
ok(v1 == v2, message + ` (${v1} == ${v2})`);
}
async function add_task(fn) {
try {
await fn();
} catch (e) {
ok(false, e.message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment