mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
add test for geoip
This commit is contained in:
1 parent
7651b0a697
commit
a8bdfa8f30
7 files changed
+26
-13
No files matched your search
@@ -14,7 +14,7 @@ export interface Result {
|
||||
display: string
|
||||
}
|
||||
|
||||
function lookup(ip: string, locale: string) {
|
||||
export function lookup(ip: string, locale: string): any {
|
||||
const res: any = reader.get(ip);
|
||||
if (!res) return {};
|
||||
const ret: Result = { display: '' };
|
||||
@@ -25,11 +25,13 @@ function lookup(ip: string, locale: string) {
|
||||
|| (res.country || res.registered_country).names.en;
|
||||
}
|
||||
if (res.city) ret.city = res.city.names[locale] || res.city.names.en;
|
||||
ret.display = `${ret.continent} ${ret.country} ${ret.city}`;
|
||||
ret.display = `${ret.continent} ${ret.country}${ret.city ? ` ${ret.city}` : ''}`;
|
||||
return ret;
|
||||
}
|
||||
|
||||
global.Hydro.lib.geoip = exports = {
|
||||
provider: '<a href="http://www.maxmind.com" target="_blank">MaxMind</a>',
|
||||
export const provider = '<a href="http://www.maxmind.com" target="_blank">MaxMind</a>';
|
||||
|
||||
global.Hydro.lib.geoip = {
|
||||
provider,
|
||||
lookup,
|
||||
};
|
||||
Reference in new issue
Block a user