hamzus-ui 0.0.133 → 0.0.134
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/package.json +1 -1
- package/src/utils/polyfill.js +17 -2
package/package.json
CHANGED
package/src/utils/polyfill.js
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
function sanitizeKeepBR(input) {
|
|
3
|
+
if (!input) return "";
|
|
4
|
+
|
|
5
|
+
// 1. échappe tout le HTML
|
|
6
|
+
let escaped = input
|
|
7
|
+
.replace(/&/g, "&")
|
|
8
|
+
.replace(/</g, "<")
|
|
9
|
+
.replace(/>/g, ">");
|
|
10
|
+
|
|
11
|
+
// 2. remet uniquement les <br> (ou \n) propres
|
|
12
|
+
return escaped
|
|
13
|
+
.replace(/<br\s*\/?>/gi, "<br>")
|
|
14
|
+
.replace(/\r?\n/g, "<br>");
|
|
15
|
+
}
|
|
2
16
|
|
|
3
17
|
export function decode(str) {
|
|
4
18
|
const txt = document.createElement("textarea");
|
|
5
19
|
txt.innerHTML = str;
|
|
6
|
-
return txt.value;
|
|
7
|
-
}
|
|
20
|
+
return sanitizeKeepBR(txt.value);
|
|
21
|
+
}
|
|
22
|
+
|