Skip to content

Commit

Permalink
fix: max cdn is down (#2151)
Browse files Browse the repository at this point in the history
* fix: max cdn no more support twmoji

* chore: prettier

---------

Co-authored-by: guanbinrui <[email protected]>
  • Loading branch information
guanbinrui and guanbinrui authored Aug 7, 2024
1 parent 2f38c4a commit 506c1eb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/helpers/loadTwemojiUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ import { parse } from 'twemoji-parser';

import { fetchText } from '@/helpers/fetchText.js';

function fixMaxCDN(url: string) {
return url.replace(
'https://twemoji.maxcdn.com/v/latest/svg/',
'https://cdn.jsdelivr.net/gh/twitter/[email protected]/assets/svg/',
);
}

export async function loadTwemojiUrls(content: string) {
const allSettled = await Promise.allSettled(
parse(content).map(async (emoji) => {
if (emoji.type !== 'emoji' || !emoji.url) return [];

const text = await fetchText(emoji.url, {
const text = await fetchText(fixMaxCDN(emoji.url), {
cache: 'force-cache',
});
if (!text) return [];
Expand Down

0 comments on commit 506c1eb

Please sign in to comment.