Skip to content

Commit

Permalink
support unescaping forward slash
Browse files Browse the repository at this point in the history
  • Loading branch information
amagee committed Aug 26, 2022
1 parent db9ba28 commit c6cfd9a
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
Original file line number Diff line number Diff line change
@@ -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 = {
'&': '&',
Expand All @@ -21,6 +21,7 @@ const htmlEntities = {
'®': '®',
'…': '…',
'…': '…',
'/': '/',
};

const unescapeHtmlEntity = (m) => htmlEntities[m];
Expand Down
4 changes: 2 additions & 2 deletions test/unescape.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { unescape } from '../src/unescape';
describe('unescape', () => {
it('should correctly unescape', () => {
const unescaped = unescape(
'& & < < > > ' ' " "     © © ® ® … …',
'& & < < > > ' ' " "     © © ® ® … … /',
);

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

0 comments on commit c6cfd9a

Please sign in to comment.