diff --git a/src/helpers.ts b/src/helpers.ts index a41bd4b..2d2f587 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -4,10 +4,12 @@ const htmlUnescapes: Record = { '>': '>', '"': '"', ''': "'", + ' ': ' ', + ' ': ' ', }; /** Used to match HTML entities and HTML characters. */ -const reEscapedHtml = /&(?:amp|lt|gt|quot|#(?:0+)?39);/g; +const reEscapedHtml = /&(?:amp|lt|gt|quot|nbsp|#(?:0+)?(?:39|160));/g; const reHasEscapedHtml = RegExp(reEscapedHtml.source); export const unescape = (str = '') => { diff --git a/tests/helpers.spec.ts b/tests/helpers.spec.ts index e3d5f3b..518ac95 100644 --- a/tests/helpers.spec.ts +++ b/tests/helpers.spec.ts @@ -15,6 +15,8 @@ describe('Helpers', () => { expect(unescape('>')).toBe('>'); expect(unescape('"')).toBe('"'); expect(unescape(''')).toBe("'"); + expect(unescape(' ')).toBe(' '); + expect(unescape(' ')).toBe(' '); expect(unescape('')).toBe(''); expect(unescape()).toBe(''); });