Skip to content

Commit

Permalink
refactor: move user agent checks to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewBastin committed Dec 17, 2021
1 parent 2f50cff commit 655e6dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import * as TE from "fp-ts/TaskEither"
import { pipe } from "fp-ts/function"
import { NetworkResponse, NetworkStrategy } from "../network"
import { browserIsChrome, browserIsFirefox } from "../utils/userAgent"

export const hasExtensionInstalled = () =>
typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined"

export const hasChromeExtensionInstalled = () =>
hasExtensionInstalled() &&
/Chrome/i.test(navigator.userAgent) &&
/Google/i.test(navigator.vendor)
hasExtensionInstalled() && browserIsChrome()

export const hasFirefoxExtensionInstalled = () =>
hasExtensionInstalled() && /Firefox/i.test(navigator.userAgent)
hasExtensionInstalled() && browserIsFirefox()

export const cancelRunningExtensionRequest = () => {
if (
Expand Down
4 changes: 4 additions & 0 deletions packages/hoppscotch-app/helpers/utils/userAgent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const browserIsChrome = () =>
/Chrome/i.test(navigator.userAgent) && /Google/i.test(navigator.vendor)

export const browserIsFirefox = () => /Firefox/i.test(navigator.userAgent)

0 comments on commit 655e6dc

Please sign in to comment.