@bhsd/common 0.4.2 → 0.4.3

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.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,11 @@ export declare const CDN = "https://testingcf.jsdelivr.net";
2
2
  declare global {
3
3
  const define: unknown;
4
4
  }
5
+ /**
6
+ * PHP的`rawurldecode`函数的JavaScript实现
7
+ * @param str 要解码的字符串
8
+ */
9
+ export declare const rawurldecode: (str: string) => string;
5
10
  /**
6
11
  * 解码标题
7
12
  * @param title 标题
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __export(src_exports, {
23
23
  loadScript: () => loadScript,
24
24
  normalizeTitle: () => normalizeTitle,
25
25
  parseVersion: () => parseVersion,
26
+ rawurldecode: () => rawurldecode,
26
27
  setObject: () => setObject,
27
28
  splitColors: () => splitColors
28
29
  });
@@ -33,8 +34,9 @@ let span;
33
34
  if (typeof document === "object") {
34
35
  span = document.createElement("span");
35
36
  }
37
+ const rawurldecode = (str) => decodeURIComponent(str.replace(/%(?![\da-f]{2})/giu, "%25"));
36
38
  const normalizeTitle = (title) => {
37
- const decoded = decodeURIComponent(title.replace(/%(?![\da-f]{2})/giu, "%25"));
39
+ const decoded = rawurldecode(title);
38
40
  if (/[<>[\]|{}]/u.test(decoded)) {
39
41
  return decoded;
40
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/common",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "license": "GPL-2.0",
5
5
  "files": [
6
6
  "/dist/",