cafe-utility 4.13.0 → 4.13.2

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.
Files changed (2) hide show
  1. package/index.js +8 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -834,15 +834,19 @@ function escapeHtml(string) {
834
834
  }
835
835
 
836
836
  const htmlEntityMap = {
837
+ '&': '&',
837
838
  '"': '"',
839
+ ''': "'",
838
840
  '>': '>',
839
- '&lt': '<'
841
+ '&lt;': '<'
840
842
  }
841
843
 
842
844
  function decodeHtmlEntities(string) {
843
- let buffer = string.replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(dec))
844
- for (const key of Object.keys(htmlEntityMap)) {
845
- buffer = buffer.split(key).join(htmlEntityMap[key])
845
+ let buffer = string
846
+ .replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(dec))
847
+ .replace(/&#x(\d+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
848
+ for (const [key, value] of Object.entries(htmlEntityMap)) {
849
+ buffer = buffer.replaceAll(key, value)
846
850
  }
847
851
  return buffer
848
852
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "4.13.0",
3
+ "version": "4.13.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {