mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-10-30 04:43:11 +08:00
v8.5.7
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -45,3 +45,4 @@ Example/**/update.json
|
|||||||
yarn-error.log
|
yarn-error.log
|
||||||
Example/testHotUpdate/.pushy
|
Example/testHotUpdate/.pushy
|
||||||
dist/
|
dist/
|
||||||
|
.cursor/mcp.json
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import { logger, promiseAny } from './utils';
|
import { logger, promiseAny } from './utils';
|
||||||
|
|
||||||
let currentEndpoint = 'https://update.react-native.cn/api';
|
let currentEndpoint = 'https://update.react-native.cn/api';
|
||||||
let backupEndpoints: string[] = [
|
let backupEndpoints: string[] = ['https://update.reactnative.cn/api'];
|
||||||
'https://pushy-koa-qgbgqmcpis.cn-beijing.fcapp.run',
|
|
||||||
'https://update.reactnative.cn/api',
|
|
||||||
];
|
|
||||||
let backupEndpointsQueryUrls = [
|
let backupEndpointsQueryUrls = [
|
||||||
'https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json',
|
'https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json',
|
||||||
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-pushy@master/endpoints.json',
|
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-pushy@master/endpoints.json',
|
||||||
|
|||||||
37
lib/utils.ts
37
lib/utils.ts
@@ -74,25 +74,30 @@ export const testUrls = async (urls?: string[]) => {
|
|||||||
return urls[0];
|
return urls[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isAndroid70AndBelow = () => {
|
// export const isAndroid70AndBelow = () => {
|
||||||
// android 7.0 and below devices do not support letsencrypt cert
|
// // android 7.0 and below devices do not support letsencrypt cert
|
||||||
// https://letsencrypt.org/2023/07/10/cross-sign-expiration/
|
// // https://letsencrypt.org/2023/07/10/cross-sign-expiration/
|
||||||
return Platform.OS === 'android' && Platform.Version <= 24;
|
// return Platform.OS === 'android' && Platform.Version <= 24;
|
||||||
};
|
// };
|
||||||
|
|
||||||
export const enhancedFetch = async (
|
export const enhancedFetch = async (
|
||||||
url: string,
|
url: string,
|
||||||
params: Parameters<typeof fetch>[1],
|
params: Parameters<typeof fetch>[1],
|
||||||
|
isRetry = false,
|
||||||
) => {
|
) => {
|
||||||
return fetch(url, params).catch((e) => {
|
return fetch(url, params)
|
||||||
logger('fetch error', url, e);
|
.then((r) => {
|
||||||
if (isAndroid70AndBelow()) {
|
if (r.ok) {
|
||||||
logger(
|
return r;
|
||||||
`try fallback to http because android version: ${Platform.Version}`,
|
}
|
||||||
);
|
throw new Error(`${r.status} ${r.statusText}`);
|
||||||
return fetch(url.replace('https', 'http'), params);
|
})
|
||||||
} else {
|
.catch((e) => {
|
||||||
throw e;
|
logger('fetch error', url, e);
|
||||||
}
|
if (isRetry) {
|
||||||
});
|
throw e;
|
||||||
|
}
|
||||||
|
logger('trying fallback to http');
|
||||||
|
return enhancedFetch(url.replace('https', 'http'), params, true);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user