Skip to content

Commit 7e2f886

Browse files
fix useragent issue on ios chrome (#28712)
1 parent 7398203 commit 7e2f886

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

examples/jsm/loaders/GLTFLoader.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,10 +2586,14 @@ class GLTFParser {
25862586

25872587
if ( typeof navigator !== 'undefined' ) {
25882588

2589-
isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
2590-
safariVersion = isSafari ? navigator.userAgent.match( /Version\/(\d+)/ )[ 1 ] : - 1;
2591-
isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
2592-
firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
2589+
const userAgent = navigator.userAgent;
2590+
2591+
isSafari = /^((?!chrome|android).)*safari/i.test( userAgent ) === true;
2592+
const safariMatch = userAgent.match( /Version\/(\d+)/ );
2593+
safariVersion = isSafari && safariMatch ? parseInt( safariMatch[ 1 ], 10 ) : - 1;
2594+
2595+
isFirefox = userAgent.indexOf( 'Firefox' ) > - 1;
2596+
firefoxVersion = isFirefox ? userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
25932597

25942598
}
25952599

0 commit comments

Comments
 (0)