diff --git a/src/html/HtmlNodeTag.js b/src/html/HtmlNodeTag.js
index 3419a02d1af..e63c83bb50c 100644
--- a/src/html/HtmlNodeTag.js
+++ b/src/html/HtmlNodeTag.js
@@ -13,6 +13,7 @@ import HtmlTagStrong from './tags/HtmlTagStrong';
import HtmlTagItalic from './tags/HtmlTagItalic';
import HtmlTagDiv from './tags/HtmlTagDiv';
import HtmlTagBr from './tags/HtmlTagBr';
+import { getEmojiUrl } from '../utils/url';
// br', 'blockquote',
@@ -64,7 +65,12 @@ export default ({ auth, attribs, name, cascadingStyle, childrenNodes, onPress }:
...stylesFromClassNames(attribs.class, cascadingStyles),
];
- const HtmlComponent = specialTags[name] || HtmlTagSpan;
+ let HtmlComponent = specialTags[name] || HtmlTagSpan;
+
+ if (attribs.class && attribs.class.startsWith('emoji emoji-')) {
+ HtmlComponent = HtmlTagImg;
+ attribs.src = getEmojiUrl(attribs.class.split('-').pop());
+ }
return (
{
});
});
+describe('getEmojiUrl', () => {
+ test('when unicode is passed, output relative link on server for emoji', () => {
+ expect(getEmojiUrl('1f680')).toBe('/static/generated/emoji/images/emoji/unicode/1f680.png');
+ });
+});
+
describe('getNarrowFromLink', () => {
const users = [
{ email: 'abc@example.com', id: 1 },
diff --git a/src/utils/url.js b/src/utils/url.js
index ef3329dbd66..813d5c7f7e9 100644
--- a/src/utils/url.js
+++ b/src/utils/url.js
@@ -35,6 +35,9 @@ export const isStreamLink = (url: string, realm: string): boolean =>
export const isSpecialLink = (url: string, realm: string): boolean =>
isUrlInAppLink(url, realm) && url.includes('is');
+export const getEmojiUrl = (unicode: string): string =>
+ `/static/generated/emoji/images/emoji/unicode/${unicode}.png`;
+
export const getNarrowFromLink = (url: string, realm: string, users: []): [] => {
const paths = url.split(realm).pop().split('/');
if (isGroupLink(url, realm)) {