make sure the check doesn't blow up
This commit is contained in:
parent
43f642a8fe
commit
ced55552da
1 changed files with 16 additions and 12 deletions
|
@ -22,18 +22,22 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function safariVersionCheck(ua) {
|
function safariVersionCheck(ua) {
|
||||||
const safariVersionMatch = ua.match(/Mac OS X ([\d|_]+).*Version\/([\d|\.]+) Safari/);
|
try {
|
||||||
if (safariVersionMatch) {
|
const safariVersionMatch = ua.match(/Mac OS X ([\d|_]+).*Version\/([\d|\.]+) Safari/);
|
||||||
const macOSVersionStr = safariVersionMatch[1];
|
if (safariVersionMatch) {
|
||||||
const safariVersionStr = safariVersionMatch[2];
|
const macOSVersionStr = safariVersionMatch[1];
|
||||||
const macOSVersion = macOSVersionStr.split("_").map(n => parseInt(n, 10));
|
const safariVersionStr = safariVersionMatch[2];
|
||||||
const safariVersion = safariVersionStr.split(".").map(n => parseInt(n, 10));
|
const macOSVersion = macOSVersionStr.split("_").map(n => parseInt(n, 10));
|
||||||
const colrFontSupported = macOSVersion[0] >= 10 && macOSVersion[1] >= 14 && safariVersion[0] >= 12;
|
const safariVersion = safariVersionStr.split(".").map(n => parseInt(n, 10));
|
||||||
// https://www.colorfonts.wtf/ states safari supports COLR fonts from this version on
|
const colrFontSupported = macOSVersion[0] >= 10 && macOSVersion[1] >= 14 && safariVersion[0] >= 12;
|
||||||
console.log(`Browser is Safari - requiring macOS 10.14 and Safari 12,` +
|
// https://www.colorfonts.wtf/ states safari supports COLR fonts from this version on
|
||||||
`detected Safari ${safariVersionStr} on macOS ${macOSVersionStr},` +
|
console.log(`Browser is Safari - requiring macOS 10.14 and Safari 12,` +
|
||||||
`supported: ${colrFontSupported}`);
|
`detected Safari ${safariVersionStr} on macOS ${macOSVersionStr},` +
|
||||||
return colrFontSupported;
|
`supported: ${colrFontSupported}`);
|
||||||
|
return colrFontSupported;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Couldn't determine Safari version to check COLR font support, assuming no.", err);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue