fix: geoip模块dts异常及prepublish.sh不调用的问题

This commit is contained in:
undefined committed 2020-09-05 21:13:29 +08:00
1 parent a1aeb521fe
commit 02c1866963
5 files changed
+10 -7

No files matched your search

+3 -2
View File
@@ -1,4 +1,5 @@
import 'hydrooj';
import 'hydrooj/src/lib/i18n';
import fs from 'fs';
import path from 'path';
import { Reader } from 'maxmind';
@@ -14,9 +15,9 @@ export interface Result {
display: string
}
export function lookup(ip: string, locale: string) {
export function lookup(ip: string, locale: string): Result {
const res: any = reader.get(ip);
if (!res) return {};
if (!res) return { display: 'Unknown address'.translate(locale) };
const ret: Result = { display: '' };
if (res.location) ret.location = res.location;
if (res.continent) ret.continent = res.continent.names[locale] || res.continent.names.en;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/geoip",
"version": "1.1.12",
"version": "1.1.13",
"main": "package.json",
"repository": "git@github.com:hydro-dev/Hydro.git",
"author": "undefined <masnn0@outlook.com>",
Regular → Executable
+4 -2
View File
@@ -1,4 +1,6 @@
wget -O ./GeoLite2-City.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${LICENSE_KEY}&suffix=tar.gz"
#!/bin/bash
get -O ./GeoLite2-City.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${LICENSE_KEY}&suffix=tar.gz"
tar zxvf ./GeoLite2-City.tar.gz -C .
mv ./GeoLite2-City_*/GeoLite2-City.mmdb ./GeoLite2-City.mmdb
rm -r ./GeoLite2-City_* ./GeoLite2-City.tar.gz
rm -r ./GeoLite2-City_* ./GeoLite2-City.tar.gz
+1 -1
View File
@@ -3,7 +3,7 @@ import * as lib from '@hydrooj/geoip/lib';
describe('geoip', () => {
test('MD5', () => {
expect(lib.lookup('127.0.0.1', 'zh_CN')).toStrictEqual({});
expect(lib.lookup('127.0.0.1', 'zh_CN').display).toStrictEqual('Unknown address');
expect(lib.lookup('1.1.1.1', 'zh-CN').display).toStrictEqual('大洋洲 澳大利亚');
expect(lib.provider.includes('MaxMind')).toBeTruthy();
});