Skip to content

Commit

Permalink
fix: Make IS_MAYBE_MIRAGE simplified
Browse files Browse the repository at this point in the history
- In previous version we fixed the code for FireFox that can now work in FireFox which has different `.toString()` implementation
- This change should make it more error prone as it completely removes whitespace from the strings and then compares them
  • Loading branch information
MichalBryxi committed May 6, 2024
1 parent 9a14b00 commit 9fdde1b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/request/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ if (DEBUG) {
IS_MAYBE_MIRAGE = () =>
Boolean(
typeof window !== 'undefined' &&
((window as { server?: { pretender: unknown } }).server?.pretender ||
(window.fetch.toString() !== 'function fetch() { [native code] }' &&
window.fetch.toString() !== 'function fetch() {\n [native code]\n}'))
(
(window as { server?: { pretender: unknown } }).server?.pretender ||
(window.fetch.toString().replace(/\s+/g, '') !== 'function fetch() { [native code] }'.replace(/\s+/g, ''))
)
);
}

Expand Down

0 comments on commit 9fdde1b

Please sign in to comment.