Fix a few compatibility issue with upgrade. Fix #81, #80

This commit is contained in:
FelisCatus 2014-12-20 12:47:31 +08:00
parent c4c8971b8e
commit bcce56320c
2 changed files with 10 additions and 0 deletions

View File

@ -50,8 +50,10 @@ module.exports = exports =
parseHostPort: (str, scheme) ->
sep = str.lastIndexOf(':')
return if sep < 0
port = parseInt(str.substr(sep + 1)) || 80
host = str.substr(0, sep)
return unless host
return {
scheme: scheme
host: host

View File

@ -158,6 +158,14 @@ module.exports = (oldOptions, i18n) ->
switch rule['patternType']
when 'wildcard'
pattern = rule['urlPattern']
if pattern[0] == '@'
pattern = pattern.substring(1)
else
if pattern.indexOf('://') <= 0 and pattern[0] != '*'
pattern = '*' + pattern
if pattern[pattern.length - 1] != '*'
pattern += '*'
host = OmegaPac.Conditions.urlWildcard2HostWildcard(pattern)
if host
conditionType: 'HostWildcardCondition'