mirror of
https://github.com/AIsouler/GKD_subscription.git
synced 2025-12-20 00:35:17 +08:00
perf: check category group name format
This commit is contained in:
13
src/file.ts
13
src/file.ts
@@ -189,8 +189,12 @@ export const checkConfig = (newConfig: RawSubscription) => {
|
|||||||
app.groups?.forEach((g) => {
|
app.groups?.forEach((g) => {
|
||||||
const oldGroup = oldGroups.find((og) => og.key == g.key);
|
const oldGroup = oldGroups.find((og) => og.key == g.key);
|
||||||
if (!oldGroup || !_.isEqual(oldGroup, g)) {
|
if (!oldGroup || !_.isEqual(oldGroup, g)) {
|
||||||
// 检查新增/变动的规则组是否能被分类捕获
|
// 检查新增/变动的规则组是否能被分类
|
||||||
if (!categories.some((c) => g.name.startsWith(c.name))) {
|
if (
|
||||||
|
!categories.some(
|
||||||
|
(c) => g.name == c.name || g.name.startsWith(c.name + '-'),
|
||||||
|
)
|
||||||
|
) {
|
||||||
console.error({
|
console.error({
|
||||||
configName: newConfig.name,
|
configName: newConfig.name,
|
||||||
appId: app.id,
|
appId: app.id,
|
||||||
@@ -200,7 +204,10 @@ export const checkConfig = (newConfig: RawSubscription) => {
|
|||||||
categories: categories.map((c) => c.name),
|
categories: categories.map((c) => c.name),
|
||||||
});
|
});
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'invalid group name, it must startsWith any category',
|
[
|
||||||
|
'invalid group name, it must equal any category name or startWith categoryName + "-".',
|
||||||
|
'example: "开屏广告" or "分段广告-朋友圈"',
|
||||||
|
].join('\n'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user