Do case-insensitive match on BEGIN/END for SwitchyRuleList. Fix #48.

And also, set the default section to WILDCARD for better compatibility.
This commit is contained in:
FelisCatus 2014-10-20 20:52:23 +08:00
parent 3badc664be
commit 2c8acfebbe
3 changed files with 9 additions and 7 deletions

View File

@ -57,17 +57,18 @@ module.exports = exports =
normal_rules = []
exclusive_rules = []
begin = false
section = 'WILDCARD'
for line in text.split(/\n|\r/)
line = line.trim()
continue if line.length == 0 || line[0] == ';'
if not begin
if line == '#BEGIN'
if line.toUpperCase() == '#BEGIN'
begin = true
continue
if line == '#END'
if line.toUpperCase() == '#END'
break
if line[0] == '[' and line[line.length - 1] == ']'
section = line.substring(1, line.length - 1)
section = line.substring(1, line.length - 1).toUpperCase()
continue
source = line
profile = matchProfileName
@ -77,10 +78,10 @@ module.exports = exports =
list = exclusive_rules
line = line.substring(1)
cond = switch section
when 'Wildcard'
when 'WILDCARD'
conditionType: 'UrlWildcardCondition'
pattern: line
when 'RegExp'
when 'REGEXP'
conditionType: 'UrlRegexCondition'
pattern: line
else

View File

@ -69,5 +69,6 @@ angular.module('omegaDecoration', []).value('profileIcons', {
ngModel.$render()
scope.getName = (profile) ->
scope.dispName?({$profile: profile}) || profile?.name
if profile
scope.dispName?({$profile: profile}) || profile?.name
)

View File

@ -8,7 +8,7 @@
.well
span.glyphicon(class='{{profileIcons[attached.profileType]}}')
= ' '
| {{attached.sourceUrl || ('options_ruleListLineCount' | tr:[attached.ruleList.split('\r?\n').length])}}
| {{attached.sourceUrl || ('options_ruleListLineCount' | tr:[attached.ruleList.split('\n').length])}}
.modal-footer
button.btn.btn-default(ng-click='$dismiss()') {{'dialog_cancel' | tr}}
button.btn.btn-danger(type='button' ng-click='$close("ok")') {{'options_deleteAttached' | tr}}