Updates
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { BUN_SQLITE_WGUI_CLIENT_RULES } from "@/db/types/db";
|
||||
|
||||
type Params = {
|
||||
rule: BUN_SQLITE_WGUI_CLIENT_RULES;
|
||||
};
|
||||
|
||||
export default function expandClientRuleDestinations({ rule }: Params) {
|
||||
if (rule.rule_type == "all") {
|
||||
return [rule];
|
||||
}
|
||||
|
||||
const destinations = (rule.destination || "")
|
||||
.split(",")
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean);
|
||||
|
||||
if (destinations.length <= 1) {
|
||||
return [
|
||||
{
|
||||
...rule,
|
||||
destination: destinations[0] || "",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return destinations.map((destination) => ({
|
||||
...rule,
|
||||
id: undefined,
|
||||
destination,
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user