hifun-tools 1.4.43 → 1.4.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,6 +21,7 @@ declare class InitCls {
21
21
  private tenantConfig;
22
22
  private tenantDict;
23
23
  private tenantDictList;
24
+ getDomain(e: string): string | null;
24
25
  /** 初始化配置入口 */
25
26
  InitConfig(options: {
26
27
  fileType?: string[];
@@ -55,6 +56,7 @@ declare class InitCls {
55
56
  private _getTenantInfoStrictSync;
56
57
  /** 匹配默认租户 */
57
58
  private _matchDefaultTenant;
59
+ getHostUrl(): string;
58
60
  retryHttp(): Promise<void>;
59
61
  refreshHttp(): Promise<void>;
60
62
  /** 获取 lineDict.txt 内容 */
@@ -1,6 +1,6 @@
1
1
  // index.ts
2
2
  import { getResource } from "./getResource";
3
- import { isDomainMatch, filterSmartLines, getOptimalDecodedString, matchBrowser, toStandardUrl, } from "./utils";
3
+ import { isDomainMatch, filterSmartLines, getOptimalDecodedString, matchBrowser, toStandardUrl, getHostUrl, } from "./utils";
4
4
  import { AesDecrypt, AesEncrypt } from "./ende";
5
5
  import { closeLoadingText, loadingText, rewardMsg } from "../msg";
6
6
  import { Cache } from "../utils";
@@ -27,6 +27,9 @@ class InitCls {
27
27
  tenantConfig = null;
28
28
  tenantDict = null;
29
29
  tenantDictList = [];
30
+ getDomain(e) {
31
+ return getDomain(e);
32
+ }
30
33
  /** 初始化配置入口 */
31
34
  async InitConfig(options) {
32
35
  const { fileType, defaultBaseUrl, localPath, appLine, appTenant, appGateway = "", backupAddress, retry = false, lineDictData, lineAddressData, // ✨ 提取参数
@@ -128,7 +131,7 @@ class InitCls {
128
131
  if (lineDictData) {
129
132
  try {
130
133
  const data = JSON.parse(AesDecrypt(lineDictData));
131
- const host = getHostUrl();
134
+ const host = this.getHostUrl();
132
135
  if (this.getIsApp()) {
133
136
  this.tenantDict = {
134
137
  browserCheck: [],
@@ -159,7 +162,7 @@ class InitCls {
159
162
  try {
160
163
  const rawText = await this._fetchLineDict();
161
164
  const data = JSON.parse(AesDecrypt(rawText));
162
- const host = getHostUrl();
165
+ const host = this.getHostUrl();
163
166
  this.tenantDictList = [...data];
164
167
  if (this.getIsApp()) {
165
168
  this.tenantDict = {
@@ -187,7 +190,7 @@ class InitCls {
187
190
  }
188
191
  /** 匹配默认租户 */
189
192
  _matchDefaultTenant() {
190
- const host = getHostUrl();
193
+ const host = this.getHostUrl();
191
194
  if (this.getIsApp()) {
192
195
  console.info("🏠 匹配到app传入租户");
193
196
  return { tenant: this.appTenant };
@@ -201,6 +204,9 @@ class InitCls {
201
204
  }
202
205
  throw new Error("无法获取有效的租户信息");
203
206
  }
207
+ getHostUrl() {
208
+ return getHostUrl(location.host);
209
+ }
204
210
  async retryHttp() {
205
211
  try {
206
212
  if (this.onlyBackUp)
@@ -413,8 +419,5 @@ class InitCls {
413
419
  }
414
420
  const HF = new InitCls();
415
421
  const t1BackGateWay = ["https://s3.t1game888.com/gateway/lineAddress.txt"];
416
- function getHostUrl() {
417
- return getDomain(location.host) ? getDomain(location.host) : location.host;
418
- }
419
422
  window.HF = HF;
420
423
  export { HF, isDomainMatch, toStandardUrl, AesEncrypt, AesDecrypt, filterSmartLines, matchBrowser, getOptimalDecodedString, };
@@ -4,6 +4,7 @@ export type TenantDict = {
4
4
  lineGroup: string;
5
5
  tenant: string;
6
6
  };
7
+ export declare function getHostUrl(e: string): string;
7
8
  /** 保留端口,去掉协议 */
8
9
  export declare function normalizeHost(hostname: string): string;
9
10
  /** 域名严格匹配,允许 www 特例 */
@@ -1,8 +1,12 @@
1
+ import { getDomain } from "tldts";
1
2
  /** 浏览器识别(结果缓存) */
2
3
  let cachedBrowser = null;
3
4
  let retryHttpTime = localStorage.getItem("retryHttpTime")
4
5
  ? Number(localStorage.getItem("retryHttpTime"))
5
6
  : 3000;
7
+ export function getHostUrl(e) {
8
+ return getDomain(e) ? getDomain(e) : e;
9
+ }
6
10
  /** 保留端口,去掉协议 */
7
11
  export function normalizeHost(hostname) {
8
12
  hostname = hostname.trim().toLowerCase();
@@ -20,7 +24,8 @@ export function normalizeHost(hostname) {
20
24
  /** 域名严格匹配,允许 www 特例 */
21
25
  export function isDomainStrictEqual(a, b) {
22
26
  const stripWww = (h) => (h.startsWith("www.") ? h.slice(4) : h);
23
- return stripWww(normalizeHost(a)) === stripWww(normalizeHost(b));
27
+ return (getHostUrl(stripWww(normalizeHost(a))) ===
28
+ getHostUrl(stripWww(normalizeHost(b))));
24
29
  }
25
30
  export function isDomainMatch(list, target) {
26
31
  const t = normalizeHost(target);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.4.42";
1
+ export declare const VERSION = "1.4.44";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.4.42";
1
+ export const VERSION = "1.4.44";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hifun-tools",
3
- "version": "1.4.43",
3
+ "version": "1.4.45",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",