Skip to content

Commit

Permalink
๐Ÿš‘ fix: mock service worker๊ฐ€ ๋“ฑ๋ก๋˜์ง€ ์•Š๋˜ ๋ฌธ์ œ ์ˆ˜์ • (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbearcookie authored Apr 22, 2024
1 parent 73d4451 commit 88dfc61
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,21 @@ const enableMocking = async () => {
});
};

const redirectIfInAppBrowser = new Promise((resolve, reject) => {
const userAgent = navigator.userAgent.toLowerCase();
const target_url = window.location.href;
const redirectIfInAppBrowser = () =>
new Promise((resolve, reject) => {
const userAgent = navigator.userAgent.toLowerCase();
const target_url = window.location.href;

if (userAgent.match(/kakaotalk/i)) {
location.href =
'kakaotalk://web/openExternal?url=' + encodeURIComponent(target_url);
reject('์™ธ๋ถ€ ๋ธŒ๋ผ์šฐ์ €๋กœ ์—ฐ๊ฒฐ');
}
if (userAgent.match(/kakaotalk/i)) {
location.href =
'kakaotalk://web/openExternal?url=' + encodeURIComponent(target_url);
reject('์™ธ๋ถ€ ๋ธŒ๋ผ์šฐ์ €๋กœ ์—ฐ๊ฒฐ');
}

resolve(true);
});
resolve(true);
});

Promise.all([enableMocking, redirectIfInAppBrowser]).then(() =>
Promise.allSettled([enableMocking(), redirectIfInAppBrowser()]).then(() =>
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<HelmetProvider>
Expand Down

0 comments on commit 88dfc61

Please sign in to comment.