-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce simple browser detection to fix Safari 14 cookies issue
* macOS 11 with Safari 14 seems to not handle 'SameSite=Strict' cookies (e.g. when redirecting to the payment provider page) correctly * the 'apiToken' cookie that handles the authentication (logged in user) state is no longer present so that the order cannot be fetched and displayed again * fix would be to not write 'SameSite=Strict' cookies in Safari 14 * the simple browser detection could be replaced if a more sophisticated version is needed
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable etc/no-deprecated, unicorn/no-null */ | ||
|
||
// simple browser and version detection: https://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser | ||
export function browserNameVersion() { | ||
const ua = navigator.userAgent; | ||
let tem; | ||
let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; | ||
if (/trident/i.test(M[1])) { | ||
tem = /\brv[ :]+(\d+)/g.exec(ua) || []; | ||
return `IE ${tem[1] || ''}`; | ||
} | ||
if (M[1] === 'Chrome') { | ||
tem = ua.match(/\b(OPR|Edge)\/(\d+)/); | ||
if (tem !== null) { | ||
return tem.slice(1).join(' ').replace('OPR', 'Opera'); | ||
} | ||
} | ||
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']; | ||
if ((tem = ua.match(/version\/(\d+)/i)) !== null) { | ||
M.splice(1, 1, tem[1]); | ||
} | ||
return M.join(' '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters