Skip to content

Commit

Permalink
support unescaping forward slash #1548
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Aug 26, 2022
1 parent 052784d commit 47230e8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
### 11.18.5

- support unescaping forward slash [1548](https://github.com/i18next/react-i18next/pull/1548)

### 11.18.4

- fix: reset t when keyPrefix is updated [1544](https://github.com/i18next/react-i18next/pull/1544)
Expand Down
6 changes: 4 additions & 2 deletions react-i18next.js
Expand Up @@ -318,7 +318,7 @@
}
};

var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230);/g;
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
var htmlEntities = {
'&': '&',
'&': '&',
Expand All @@ -337,7 +337,9 @@
'®': '®',
'®': '®',
'…': '…',
'…': '…'
'…': '…',
'/': '/',
'/': '/'
};

var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
Expand Down
2 changes: 1 addition & 1 deletion react-i18next.min.js

Large diffs are not rendered by default.

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

const htmlEntities = {
'&': '&',
Expand All @@ -22,6 +22,7 @@ const htmlEntities = {
'…': '…',
'…': '…',
'/': '/',
'/': '/',
};

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(
'& & < < > > ' ' " "     © © ® ® … … /',
'& & < < > > ' ' " "     © © ® ® … … / /',
);

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

0 comments on commit 47230e8

Please sign in to comment.