api/core: fix link parsing error handling

This commit is contained in:
wukko
2024-08-24 16:13:42 +06:00
parent cc05833c6a
commit 7041d61d80
3 changed files with 20 additions and 7 deletions

View File

@@ -163,11 +163,11 @@ export function extract(url) {
const host = getHostIfValid(url);
if (!host) {
return { error: "unsupported" };
return { error: "link.invalid" };
}
if (!env.enabledServices.has(host)) {
return { error: "disabled" };
return { error: "service.disabled" };
}
let patternMatch;
@@ -182,7 +182,12 @@ export function extract(url) {
}
if (!patternMatch) {
return null;
return {
error: "link.unsupported",
context: {
service: host
}
};
}
return { host, patternMatch };