Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative emoji paths in emojify function #748

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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