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