mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-10-29 20:43:09 +08:00
v10.13.0
This commit is contained in:
11
src/utils.ts
11
src/utils.ts
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user