添加测试用例。

pull/279/head
王良 2024-03-26 12:02:42 +08:00
parent efc6bddf07
commit bba04117d0
2 changed files with 11 additions and 2 deletions

View File

@ -32,7 +32,7 @@ function domainMapRegexply (hostMap) {
}
function matchHostname (hostMap, hostname, action) {
log.error('matchHostname:', action, hostMap)
// log.error('matchHostname:', action, hostMap)
if (hostMap == null) {
log.warn(`matchHostname: ${action}: '${hostname}' Not-Matched, hostMap is null`)

View File

@ -4,7 +4,8 @@ const hostMap = matchUtil.domainMapRegexply({
'aaa.com': true,
'*bbb.com': true,
'*.ccc.com': true,
'^.{1,3}ddd.com$': true
'^.{1,3}ddd.com$': true,
'*.cn': true
})
console.log(hostMap)
@ -42,3 +43,11 @@ const value43 = matchUtil.matchHostname(hostMap, 'xddd.com', 'test4.3')
console.log(value41) // undefined
console.log(value42) // true
console.log(value43) // true
console.log('test5: *.cn')
const value51 = matchUtil.matchHostname(hostMap, 'eee.cn', 'test5.1')
const value52 = matchUtil.matchHostname(hostMap, 'x.eee.cn', 'test5.2')
const value53 = matchUtil.matchHostname(hostMap, 'aaaa.cnet.com', 'test5.3')
console.log(value51) // true
console.log(value52) // true
console.log(value53) // undefined