Skip to content

Commit

Permalink
Use relative emoji paths in emojify function (#748)
Browse files Browse the repository at this point in the history
Refs #742
  • Loading branch information
dbrgn authored Jan 31, 2019
1 parent 27d8ca6 commit 1dd7224
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/helpers/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3759,7 +3759,7 @@ export function emojify(text: string): string {
if (text !== null) {
return twemoji.parse(text, {
callback: (icon, options, variant) => {
return '/emoji/png32/' + icon + '.png';
return 'emoji/png32/' + icon + '.png';
},
attributes: (icon, variant) => {
return {'data-c': variant};
Expand Down
10 changes: 5 additions & 5 deletions tests/ts/emoji_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Emoji Helpers', () => {
it('emojifies with img tag', function() {
expect(emojify('hello 🐦'))
.toEqual('hello <img class="em" draggable="false" '
+ 'alt="🐦" src="/emoji/png32/1f426.png" data-c="1f426"/>');
+ 'alt="🐦" src="emoji/png32/1f426.png" data-c="1f426"/>');
});

it('ignores certain codepoints', function() {
Expand Down Expand Up @@ -57,13 +57,13 @@ describe('Emoji Helpers', () => {

const singleEmojiClassName = 'large-emoji';
const crazy = '<img class="em" draggable="false"'
+ ' alt="🤪" src="/emoji/png32/1f92a.png" data-c="1f92a">';
+ ' alt="🤪" src="emoji/png32/1f92a.png" data-c="1f92a">';
const crazyLarge = '<img class="em ' + singleEmojiClassName
+ '" draggable="false" alt="🤪" src="/emoji/png64/1f92a.png" data-c="1f92a">';
+ '" draggable="false" alt="🤪" src="emoji/png64/1f92a.png" data-c="1f92a">';
const copyright = '<img class="em anotherclass" draggable="false"'
+ ' alt="©️" src="/emoji/png32/a9.png" data-c="a9">';
+ ' alt="©️" src="emoji/png32/a9.png" data-c="a9">';
const copyrightLarge = '<img class="em ' + singleEmojiClassName
+ ' anotherclass" draggable="false" alt="©️" src="/emoji/png64/a9.png" data-c="a9">';
+ ' anotherclass" draggable="false" alt="©️" src="emoji/png64/a9.png" data-c="a9">';

it('enlarges 1 emoji', () => {
expect(process(crazy)).toEqual(crazyLarge);
Expand Down

0 comments on commit 1dd7224

Please sign in to comment.