mirror of
https://github.com/metowolf/iplist.git
synced 2025-12-20 00:34:49 +08:00
优化中国行政区码识别逻辑
This commit is contained in:
@@ -3,8 +3,12 @@ const list = require('./data')
|
||||
const query = (country, region, city) => {
|
||||
if (country === '中国') {
|
||||
if (list[region]) {
|
||||
const result = list[region][city] || list[region][region]
|
||||
return result.toString()
|
||||
if (!city) {
|
||||
return list[region][region].toString()
|
||||
}
|
||||
if (list[region][city]) {
|
||||
return list[region][city].toString()
|
||||
}
|
||||
}
|
||||
// 尝试前缀匹配
|
||||
for (const key in list) {
|
||||
@@ -29,7 +33,7 @@ const query = (country, region, city) => {
|
||||
if (country === '中国澳门') {
|
||||
return '820000'
|
||||
}
|
||||
if (country === '中国台湾') {
|
||||
if (country === '中国台湾' || country === '台湾') {
|
||||
return '710000'
|
||||
}
|
||||
return ''
|
||||
|
||||
Reference in New Issue
Block a user