fix: guard against undefined entry in domainLink helper
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Add null checks to prevent runtime errors when the domain index entry does not exist for the given identifier.
This commit is contained in:
parent
6dfe3f9d42
commit
8e2e38757f
1 changed files with 6 additions and 1 deletions
|
|
@ -110,5 +110,10 @@ export const domains_by_groups = derived(domains, ($domains: Array<Domain> | und
|
|||
});
|
||||
|
||||
export function domainLink(dnid: string): string {
|
||||
return get(domains_idx)[get(domains_idx)[dnid].domain] ? get(domains_idx)[dnid].domain : dnid;
|
||||
const idx = get(domains_idx);
|
||||
const entry = idx[dnid];
|
||||
if (entry && idx[entry.domain]) {
|
||||
return entry.domain;
|
||||
}
|
||||
return dnid;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue