hifun-tools 1.4.44 → 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.
@@ -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";
@@ -205,7 +205,7 @@ class InitCls {
205
205
  throw new Error("无法获取有效的租户信息");
206
206
  }
207
207
  getHostUrl() {
208
- return getDomain(location.host) ? getDomain(location.host) : location.host;
208
+ return getHostUrl(location.host);
209
209
  }
210
210
  async retryHttp() {
211
211
  try {
@@ -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.43";
1
+ export declare const VERSION = "1.4.44";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.4.43";
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.44",
3
+ "version": "1.4.45",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",