Skip to content

Commit 1883c9e

Browse files
committed
Fix case where content is null or empty
1 parent afaabd5 commit 1883c9e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

OpenGraphDisplay.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,17 @@ export default class OpenGraphDisplay extends Component {
9191
);
9292
};
9393

94-
unescape = (content) => unescape(
95-
content.replace(/&#([0-9]{1,3});/gi, (match, numStr) => (
96-
String.fromCharCode(Number(numStr))
97-
))
98-
);
94+
unescape = (content) => {
95+
if (!content) {
96+
return '';
97+
}
98+
99+
return unescape(
100+
content.replace(/&#([0-9]{1,3});/gi, (match, numStr) => (
101+
String.fromCharCode(Number(numStr))
102+
))
103+
);
104+
}
99105

100106
render() {
101107
if (!this.props.data.url) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-opengraph-kit",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "A set of components and utils useful to extract opengraph data directly from your react-native app",
55
"main": "index.js",
66
"devDependencies": {

0 commit comments

Comments
 (0)