refactor: move user agent checks to separate file
This commit is contained in:
@@ -1,17 +1,16 @@
|
|||||||
import * as TE from "fp-ts/TaskEither"
|
import * as TE from "fp-ts/TaskEither"
|
||||||
import { pipe } from "fp-ts/function"
|
import { pipe } from "fp-ts/function"
|
||||||
import { NetworkResponse, NetworkStrategy } from "../network"
|
import { NetworkResponse, NetworkStrategy } from "../network"
|
||||||
|
import { browserIsChrome, browserIsFirefox } from "../utils/userAgent"
|
||||||
|
|
||||||
export const hasExtensionInstalled = () =>
|
export const hasExtensionInstalled = () =>
|
||||||
typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined"
|
typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined"
|
||||||
|
|
||||||
export const hasChromeExtensionInstalled = () =>
|
export const hasChromeExtensionInstalled = () =>
|
||||||
hasExtensionInstalled() &&
|
hasExtensionInstalled() && browserIsChrome()
|
||||||
/Chrome/i.test(navigator.userAgent) &&
|
|
||||||
/Google/i.test(navigator.vendor)
|
|
||||||
|
|
||||||
export const hasFirefoxExtensionInstalled = () =>
|
export const hasFirefoxExtensionInstalled = () =>
|
||||||
hasExtensionInstalled() && /Firefox/i.test(navigator.userAgent)
|
hasExtensionInstalled() && browserIsFirefox()
|
||||||
|
|
||||||
export const cancelRunningExtensionRequest = () => {
|
export const cancelRunningExtensionRequest = () => {
|
||||||
if (
|
if (
|
||||||
|
|||||||
4
packages/hoppscotch-app/helpers/utils/userAgent.ts
Normal file
4
packages/hoppscotch-app/helpers/utils/userAgent.ts
Normal 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)
|
||||||
Reference in New Issue
Block a user