Skip to content

Commit

Permalink
Update detectIncognito.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
MarianoFacundoArch authored Nov 22, 2024
1 parent 2432aec commit 991012b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/detectIncognito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function detectIncognito(): Promise<{ isPrivate: boolean; browserNa
function feid (): number {
let toFixedEngineID = 0
try {
(-1).toFixed(-1)
eval(`(-1).toFixed(-1);`);
} catch (e) {
toFixedEngineID = (e as Error).message.length // Safari 44, Chrome 51, Firefox 25
}
Expand Down Expand Up @@ -260,4 +260,4 @@ if (typeof window !== 'undefined') {
window.detectIncognito = detectIncognito;
}

export default detectIncognito;
export default detectIncognito;

1 comment on commit 991012b

@mvogelenzang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume eval here is needed to detect certain behavior in the browsers which tells us if we are in Private/Incognito mode but this will cause Rollup to complain.

If you want to turn it off, add this to your rollup config:

onwarn(warning, warn) {
    if (warning.code === 'EVAL') {
        if (warning.id && warning.id.includes('detectincognitojs')) return;
    }
    warn(warning);
}

Please sign in to comment.