feat: add Page Rules For Matching Tags (#1418)
* Added Page Rules For Matching Tags * fix: use T as Tag Match icon * fix: reorder page rules in checkAccess * fix: common controller tags code refactor Co-authored-by: Nicolas Giard <github@ngpixel.com>
This commit is contained in:
@@ -176,20 +176,31 @@ module.exports = {
|
||||
switch (rule.match) {
|
||||
case 'START':
|
||||
if (_.startsWith(`/${page.path}`, `/${rule.path}`)) {
|
||||
checkState = this._applyPageRuleSpecificity({ rule, checkState, higherPriority: ['END', 'REGEX', 'EXACT'] })
|
||||
checkState = this._applyPageRuleSpecificity({ rule, checkState, higherPriority: ['END', 'REGEX', 'EXACT', 'TAG'] })
|
||||
}
|
||||
break
|
||||
case 'END':
|
||||
if (_.endsWith(page.path, rule.path)) {
|
||||
checkState = this._applyPageRuleSpecificity({ rule, checkState, higherPriority: ['REGEX', 'EXACT'] })
|
||||
checkState = this._applyPageRuleSpecificity({ rule, checkState, higherPriority: ['REGEX', 'EXACT', 'TAG'] })
|
||||
}
|
||||
break
|
||||
case 'REGEX':
|
||||
const reg = new RegExp(rule.path)
|
||||
if (reg.test(page.path)) {
|
||||
checkState = this._applyPageRuleSpecificity({ rule, checkState, higherPriority: ['EXACT'] })
|
||||
checkState = this._applyPageRuleSpecificity({ rule, checkState, higherPriority: ['EXACT', 'TAG'] })
|
||||
}
|
||||
break
|
||||
case 'TAG':
|
||||
_.get(page, 'tags', []).forEach(tag => {
|
||||
if (tag.tag === rule.path) {
|
||||
checkState = this._applyPageRuleSpecificity({
|
||||
rule,
|
||||
checkState,
|
||||
higherPriority: ['EXACT']
|
||||
})
|
||||
}
|
||||
})
|
||||
break
|
||||
case 'EXACT':
|
||||
if (`/${page.path}` === `/${rule.path}`) {
|
||||
checkState = this._applyPageRuleSpecificity({ rule, checkState, higherPriority: [] })
|
||||
|
Reference in New Issue
Block a user