From 33f2341f7f05b034383015ec79dfe9f97cf3785c Mon Sep 17 00:00:00 2001 From: Levin Rickert Date: Thu, 20 Feb 2020 19:22:10 +0100 Subject: [PATCH 1/2] Update link to extension repo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0093dee15..fa60e90b5 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ _**All `i18n` contributions are welcome to `i18n` [branch](https://github.com/li - **[CLI β](https://github.com/postwoman-io/postwoman-cli)** - A CLI solution for Postwoman - **Browser Extensions** - Browser extensions that simplifies access to Postwoman - [![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_16x16.png) **Firefox**](https://addons.mozilla.org/en-US/firefox/addon/postwoman) ([GitHub](https://github.com/AndrewBastin/postwoman-firefox))  |  [![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_16x16.png) **Chrome**](https://chrome.google.com/webstore/detail/postwoman-extension-for-c/amknoiejhlmhancpahfcfcfhllgkpbld) ([GitHub](https://github.com/AndrewBastin/postwoman-chrome)) + [![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_16x16.png) **Firefox**](https://addons.mozilla.org/en-US/firefox/addon/postwoman)  |  [![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_16x16.png) **Chrome**](https://chrome.google.com/webstore/detail/postwoman-extension-for-c/amknoiejhlmhancpahfcfcfhllgkpbld) ([GitHub](https://github.com/AndrewBastin/postwoman-extension)) >**Extensions fixes `CORS` issues.** From f636e7dbd4c88e9464296c4ae0541f762332d443 Mon Sep 17 00:00:00 2001 From: Levin Rickert Date: Thu, 20 Feb 2020 19:36:30 +0100 Subject: [PATCH 2/2] Adapt extension check to new extensions --- functions/network.js | 6 ++++-- functions/strategies/ExtensionStrategy.js | 3 +++ layouts/default.vue | 8 +++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/functions/network.js b/functions/network.js index 22ff13364..57cc634b8 100644 --- a/functions/network.js +++ b/functions/network.js @@ -1,5 +1,7 @@ import AxiosStrategy from "./strategies/AxiosStrategy"; -import ExtensionStrategy from "./strategies/ExtensionStrategy"; +import ExtensionStrategy, { + hasExtensionInstalled +} from "./strategies/ExtensionStrategy"; import FirefoxStrategy from "./strategies/FirefoxStrategy"; import ChromeStrategy, { hasChromeExtensionInstalled @@ -11,7 +13,7 @@ const isExtensionsAllowed = ({ state }) => const runAppropriateStrategy = (req, store) => { if (isExtensionsAllowed(store)) { - if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined") { + if (hasExtensionInstalled()) { return ExtensionStrategy(req, store); } diff --git a/functions/strategies/ExtensionStrategy.js b/functions/strategies/ExtensionStrategy.js index 837498a1d..e12e167e8 100644 --- a/functions/strategies/ExtensionStrategy.js +++ b/functions/strategies/ExtensionStrategy.js @@ -1,3 +1,6 @@ +export const hasExtensionInstalled = () => + typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined"; + const extensionWithProxy = async (req, { state }) => { const { data } = await window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({ method: "post", diff --git a/layouts/default.vue b/layouts/default.vue index 2308fe971..7c0ec7f17 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -668,7 +668,7 @@