mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix(body_rules): 启用条件的规则跳过路径冲突校验
条件可能互斥,静态校验无法判断是否真正冲突,改为运行时处理。
This commit is contained in:
@@ -1424,8 +1424,10 @@ function validateBodyRulePathForEndpoint(endpointId: string, path: string, index
|
|||||||
const normalizedPath = raw.toLowerCase()
|
const normalizedPath = raw.toLowerCase()
|
||||||
|
|
||||||
const rules = getEndpointEditBodyRules(endpointId)
|
const rules = getEndpointEditBodyRules(endpointId)
|
||||||
|
const currentRule = rules[index]
|
||||||
|
// 任意一方启用了条件,则不视为冲突(条件可能互斥,真正冲突在运行时处理)
|
||||||
const duplicate = rules.findIndex(
|
const duplicate = rules.findIndex(
|
||||||
(r, i) => i !== index && (
|
(r, i) => i !== index && !currentRule.conditionEnabled && !r.conditionEnabled && (
|
||||||
((r.action === 'set' || r.action === 'drop') && r.path.trim().toLowerCase() === normalizedPath) ||
|
((r.action === 'set' || r.action === 'drop') && r.path.trim().toLowerCase() === normalizedPath) ||
|
||||||
(r.action === 'rename' && r.to.trim().toLowerCase() === normalizedPath)
|
(r.action === 'rename' && r.to.trim().toLowerCase() === normalizedPath)
|
||||||
)
|
)
|
||||||
@@ -1455,8 +1457,9 @@ function validateBodyRenameFromForEndpoint(endpointId: string, from: string, ind
|
|||||||
const normalizedFrom = raw.toLowerCase()
|
const normalizedFrom = raw.toLowerCase()
|
||||||
|
|
||||||
const rules = getEndpointEditBodyRules(endpointId)
|
const rules = getEndpointEditBodyRules(endpointId)
|
||||||
|
const currentRule = rules[index]
|
||||||
const duplicate = rules.findIndex(
|
const duplicate = rules.findIndex(
|
||||||
(r, i) => i !== index &&
|
(r, i) => i !== index && !currentRule.conditionEnabled && !r.conditionEnabled &&
|
||||||
((r.action === 'set' && r.path.trim().toLowerCase() === normalizedFrom) ||
|
((r.action === 'set' && r.path.trim().toLowerCase() === normalizedFrom) ||
|
||||||
(r.action === 'drop' && r.path.trim().toLowerCase() === normalizedFrom) ||
|
(r.action === 'drop' && r.path.trim().toLowerCase() === normalizedFrom) ||
|
||||||
(r.action === 'rename' && r.from.trim().toLowerCase() === normalizedFrom))
|
(r.action === 'rename' && r.from.trim().toLowerCase() === normalizedFrom))
|
||||||
@@ -1486,8 +1489,9 @@ function validateBodyRenameToForEndpoint(endpointId: string, to: string, index:
|
|||||||
const normalizedTo = raw.toLowerCase()
|
const normalizedTo = raw.toLowerCase()
|
||||||
|
|
||||||
const rules = getEndpointEditBodyRules(endpointId)
|
const rules = getEndpointEditBodyRules(endpointId)
|
||||||
|
const currentRule = rules[index]
|
||||||
const duplicate = rules.findIndex(
|
const duplicate = rules.findIndex(
|
||||||
(r, i) => i !== index &&
|
(r, i) => i !== index && !currentRule.conditionEnabled && !r.conditionEnabled &&
|
||||||
((r.action === 'set' && r.path.trim().toLowerCase() === normalizedTo) ||
|
((r.action === 'set' && r.path.trim().toLowerCase() === normalizedTo) ||
|
||||||
(r.action === 'rename' && r.to.trim().toLowerCase() === normalizedTo))
|
(r.action === 'rename' && r.to.trim().toLowerCase() === normalizedTo))
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user