Skip to content

Commit

Permalink
fix: chrome 판단 regex 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
eonseok-jeon committed Oct 22, 2024
1 parent 95d2c53 commit 9db6557
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/common/hooks/useCheckBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ import { useEffect } from 'react';

const useCheckBrowser = () => {
useEffect(() => {
const isChrome = /Chrome/i.test(window.navigator.userAgent);
const userAgent = window.navigator.userAgent;

const chromeRegexes = [
/\b(?:crmo|crios)\/([\w\.]+)/i, // Chrome for Android/iOS
/headlesschrome(?:\/([\w\.]+)| )/i, // Chrome Headless
/ wv\).+(chrome)\/([\w\.]+)/i, // Chrome WebView
/chrome\/([\w\.]+) mobile/i, // Chrome Mobile
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i, // ChromeOS (Chromium OS)
];

const isChrome = chromeRegexes.some((regex) => regex.test(userAgent));

if (!isChrome) {
alert('원활한 지원을 위해 크롬(Chrome) 브라우저 사용을 권장드려요.');
}
Expand Down

0 comments on commit 9db6557

Please sign in to comment.