1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-29 20:43:09 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm
2024-08-26 18:52:44 +08:00
parent d000c40e0f
commit 94d2e18900
5 changed files with 27 additions and 25 deletions

View File

@@ -31,9 +31,18 @@ const ping =
const canUseGoogle = ping('https://www.google.com');
export function joinUrls(paths: string[], fileName?: string) {
if (fileName) {
return paths.map(path => 'https://' + path + '/' + fileName);
}
}
export const testUrls = async (urls?: string[]) => {
if (!urls?.length || (await canUseGoogle)) {
if (!urls?.length) {
return null;
}
if (await canUseGoogle) {
return urls[0];
}
return Promise.race(urls.map(ping)).catch(() => null);
};