@bhsd/common 0.2.0 → 0.3.0
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 +5 -0
- package/dist/index.js +13 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
export const CDN = 'https://testingcf.jsdelivr.net';
|
|
2
|
-
const hexColor = String.raw `#(?:[\da-f]{3,4}|(?:[\da-f]{2}){3,4})(?![\p{L}\d_])`, rgbColor = String.raw `rgba?\(\s*(?:${String.raw `[\d.]+\s+[\d.]+\s+[\d.]+(?:\s*\/\s*[\d.]+%?)?`}|${String.raw `[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+(?:\s*,\s*[\d.]+%?)?`})\s*\)`, re = new RegExp(String.raw `(^|[^\p{L}\d_])(${hexColor}|${rgbColor})`, 'giu');
|
|
2
|
+
const hexColor = String.raw `#(?:[\da-f]{3,4}|(?:[\da-f]{2}){3,4})(?![\p{L}\d_])`, rgbColor = String.raw `rgba?\(\s*(?:${String.raw `[\d.]+\s+[\d.]+\s+[\d.]+(?:\s*\/\s*[\d.]+%?)?`}|${String.raw `[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+(?:\s*,\s*[\d.]+%?)?`})\s*\)`, re = new RegExp(String.raw `(^|[^\p{L}\d_])(${hexColor}|${rgbColor})`, 'giu'), span = document.createElement('span');
|
|
3
|
+
/**
|
|
4
|
+
* 解码标题
|
|
5
|
+
* @param title 标题
|
|
6
|
+
*/
|
|
7
|
+
export const normalizeTitle = (title) => {
|
|
8
|
+
const decoded = decodeURIComponent(title.replace(/%(?![\da-f]{2})/giu, '%25'));
|
|
9
|
+
if (/[<>[\]|{}]/u.test(decoded)) {
|
|
10
|
+
return decoded;
|
|
11
|
+
}
|
|
12
|
+
span.innerHTML = decoded;
|
|
13
|
+
return span.textContent;
|
|
14
|
+
};
|
|
3
15
|
/**
|
|
4
16
|
* 包含颜色时断开字符串
|
|
5
17
|
* @param str 字符串
|