refactor: move user agent checks to separate file

This commit is contained in:
Andrew Bastin
2021-12-17 15:10:06 +05:30
parent 2f50cff404
commit 655e6dc2a4
2 changed files with 7 additions and 4 deletions

View File

@@ -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 (

View File

@@ -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)