Skip to content

Commit

Permalink
support unescaping forward slash (#1548)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Magee <amagee@gmail.com>
  • Loading branch information
amagee-willow and amagee committed Aug 26, 2022
1 parent db9ba28 commit 052784d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/unescape.js
@@ -1,6 +1,6 @@
// unescape common html entities

const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F);/g;

const htmlEntities = {
'&amp;': '&',
Expand All @@ -21,6 +21,7 @@ const htmlEntities = {
'&#174;': '®',
'&hellip;': '…',
'&#8230;': '…',
'&#x2F;': '/',
};

const unescapeHtmlEntity = (m) => htmlEntities[m];
Expand Down
4 changes: 2 additions & 2 deletions test/unescape.spec.js
Expand Up @@ -3,9 +3,9 @@ import { unescape } from '../src/unescape';
describe('unescape', () => {
it('should correctly unescape', () => {
const unescaped = unescape(
'&amp; &#38; &lt; &#60; &gt; &#62; &apos; &#39; &quot; &#34; &nbsp; &#160; &copy; &#169; &reg; &#174; &hellip; &#8230;',
'&amp; &#38; &lt; &#60; &gt; &#62; &apos; &#39; &quot; &#34; &nbsp; &#160; &copy; &#169; &reg; &#174; &hellip; &#8230; &#x2F;',
);

expect(unescaped).toEqual('& & < < > > \' \' " " © © ® ® … …');
expect(unescaped).toEqual('& & < < > > \' \' " " © © ® ® … … /');
});
});

0 comments on commit 052784d

Please sign in to comment.