Skip to content

Commit 4ac567d

Browse files
author
Nathan Downs
committed
TwemojiParser: Switch to defaulting to 'v/latest' URLs from MaxCDN
**Problem** The `twemoji-parser` project defaults emoji urls to their old `/2/` paths on MaxCDN **Solution** Use `/v/latest/` as the default for parsed emoji urls on MaxCDN
1 parent ec14aa8 commit 4ac567d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ const entities = parse('I 🧡 Twemoji! 🥳');
2020
/*
2121
entities = [
2222
{
23-
url: 'https://twemoji.maxcdn.com/2/svg/1f9e1.svg',
23+
url: 'https://twemoji.maxcdn.com/v/latest/svg/1f9e1.svg',
2424
indices: [ 2, 4 ],
2525
text: '🧡',
2626
type: 'emoji'
2727
},
2828
{
29-
url: 'https://twemoji.maxcdn.com/2/svg/1f973.svg',
29+
url: 'https://twemoji.maxcdn.com/v/latest/svg/1f973.svg',
3030
indices: [ 12, 14 ],
3131
text: '🥳',
3232
type: 'emoji'

src/__tests__/index.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,23 @@ describe('parse', () => {
9898
test('use MaxCDN SVGs by default', () => {
9999
expect(parse('I \u2764 emoji!')).toMatchObject([
100100
{
101-
url: 'https://twemoji.maxcdn.com/2/svg/2764.svg'
101+
url: 'https://twemoji.maxcdn.com/v/latest/svg/2764.svg'
102102
}
103103
]);
104104
});
105105

106106
test('can ask for MaxCDN PNGs', () => {
107107
expect(parse('I \u2764 emoji!', { assetType: 'png' })).toMatchObject([
108108
{
109-
url: 'https://twemoji.maxcdn.com/2/72x72/2764.png'
109+
url: 'https://twemoji.maxcdn.com/v/latest/72x72/2764.png'
110110
}
111111
]);
112112
});
113113

114-
test('unrecognized assetType defaults back to SVG', () => {
115-
expect(parse('I \u2764 emoji!', { assetType: 'svg' })).toMatchObject([
114+
test('non-png assetType defaults back to SVG', () => {
115+
expect(parse('I \u2764 emoji!', { assetType: 'foobar' })).toMatchObject([
116116
{
117-
url: 'https://twemoji.maxcdn.com/2/svg/2764.svg'
117+
url: 'https://twemoji.maxcdn.com/v/latest/svg/2764.svg'
118118
}
119119
]);
120120
});

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export function parse(text: string, options?: ParsingOptions): Array<EmojiEntity
2424
? options.buildUrl
2525
: (codepoints, assetType) =>
2626
assetType === 'png'
27-
? `https://twemoji.maxcdn.com/2/72x72/${codepoints}.png`
28-
: `https://twemoji.maxcdn.com/2/svg/${codepoints}.svg`;
27+
? `https://twemoji.maxcdn.com/v/latest/72x72/${codepoints}.png`
28+
: `https://twemoji.maxcdn.com/v/latest/svg/${codepoints}.svg`;
2929

3030
const entities = [];
3131

0 commit comments

Comments
 (0)