1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-08 23:25:15 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

test cdn urls

This commit is contained in:
sunnylqm
2024-07-26 15:37:32 +08:00
parent fcfc8c3dbb
commit ab1e62dba5
3 changed files with 34 additions and 25 deletions

View File

@@ -23,10 +23,9 @@ const ping =
new Promise(r => setTimeout(() => r(null), 2000)),
]);
const canUseGoogle = ping('https://www.google.com');
export const testUrls = async (urls?: string[]) => {
if (!urls?.length || (await canUseGoogle)) {
if (!urls?.length) {
return null;
}
return Promise.race(urls.map(ping)).catch(() => null);