@@ -40,13 +40,13 @@ const ping =
4040 : async ( url : string ) => {
4141 let pingFinished = false ;
4242 return Promise . race ( [
43- fetch ( url , {
43+ enhancedFetch ( url , {
4444 method : 'HEAD' ,
4545 } )
46- . then ( ( { status, statusText } ) => {
46+ . then ( ( { status, statusText, url : finalUrl } ) => {
4747 pingFinished = true ;
4848 if ( status === 200 ) {
49- return url ;
49+ return finalUrl ;
5050 }
5151 log ( 'ping failed' , url , status , statusText ) ;
5252 throw new Error ( 'Ping failed' ) ;
@@ -69,7 +69,7 @@ const ping =
6969
7070export function joinUrls ( paths : string [ ] , fileName ?: string ) {
7171 if ( fileName ) {
72- return paths . map ( path => ' https://' + path + '/' + fileName ) ;
72+ return paths . map ( path => ` https://${ path } / ${ fileName } ` ) ;
7373 }
7474}
7575
@@ -108,3 +108,23 @@ export const assertDev = (matter: string) => {
108108 }
109109 return true ;
110110} ;
111+
112+ export const isAndroid70AndBelow = ( ) => {
113+ // android 7.0 and below devices do not support letsencrypt cert
114+ // https://letsencrypt.org/2023/07/10/cross-sign-expiration/
115+ return Platform . OS === 'android' && Platform . Version <= 24 ;
116+ } ;
117+
118+ export const enhancedFetch = async (
119+ url : string ,
120+ params : Parameters < typeof fetch > [ 1 ] ,
121+ ) => {
122+ return fetch ( url , params ) . catch ( e => {
123+ log ( 'fetch error' , url , e ) ;
124+ if ( isAndroid70AndBelow ( ) ) {
125+ log ( `try fallback to http because android version: ${ Platform . Version } ` ) ;
126+ return fetch ( url . replace ( 'https' , 'http' ) , params ) ;
127+ }
128+ throw e ;
129+ } ) ;
130+ } ;
0 commit comments