From 85c8f3a147dadf4b9f1c9a1ad9dd79bffb306d84 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:22:25 -0800 Subject: [PATCH 1/9] feat: different countly keys for kubo and webui.ipfs.io deployments --- src/bundles/analytics.js | 15 ++++++++++++--- src/env.js | 20 ++++++++++++++++++++ tsconfig.json | 1 + 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/env.js diff --git a/src/bundles/analytics.js b/src/bundles/analytics.js index 1cdbdb44a..6d12f9e0d 100644 --- a/src/bundles/analytics.js +++ b/src/bundles/analytics.js @@ -9,6 +9,7 @@ import { ACTIONS as FILES } from './files/consts' import { ACTIONS as CONIFG } from './config-save' import { ACTIONS as INIT } from './ipfs-provider' import { ACTIONS as EXP } from './experiments' +import { getDeploymentEnv } from '../env' /** * @typedef {import('./ipfs-provider').Init} Init @@ -91,13 +92,22 @@ const ASYNC_ACTIONS_TO_RECORD = [ const COUNTLY_KEY_WEBUI = '8fa213e6049bff23b08e5f5fbac89e7c27397612' const COUNTLY_KEY_WEBUI_TEST = '700fd825c3b257e021bd9dbc6cbf044d33477531' +const COUNTLY_KEY_WEBUI_KUBO = 'c4524cc93fed92a5838d4ea27c5a65526b4e7558' -function pickAppKey () { +/** + * @see https://github.com/ipfs/ipfs-webui/issues/2078 + * @returns {Promise} + */ +async function pickAppKey () { const isProd = process.env.NODE_ENV === 'production' if (root.ipfsDesktop && root.ipfsDesktop.countlyAppKey) { return root.ipfsDesktop.countlyAppKey } else { + const env = await getDeploymentEnv() + if (env === 'kubo') { + return COUNTLY_KEY_WEBUI_KUBO + } return isProd ? COUNTLY_KEY_WEBUI : COUNTLY_KEY_WEBUI_TEST } } @@ -262,7 +272,6 @@ const actions = { const createAnalyticsBundle = ({ countlyUrl = 'https://countly.ipfs.io', - countlyAppKey = pickAppKey(), appVersion = process.env.REACT_APP_VERSION, // @ts-ignore - declared but never used appGitRevision = process.env.REACT_APP_GIT_REV, @@ -294,7 +303,7 @@ const createAnalyticsBundle = ({ Countly.require_consent = true Countly.url = countlyUrl - Countly.app_key = countlyAppKey + Countly.app_key = await pickAppKey() Countly.app_version = appVersion Countly.debug = debug diff --git a/src/env.js b/src/env.js new file mode 100644 index 000000000..9820bc7ab --- /dev/null +++ b/src/env.js @@ -0,0 +1,20 @@ + +/** + * @see https://github.com/ipfs/ipfs-webui/issues/2078#issuecomment-1384444232 + * @returns {Promise<'local'|'kubo'|'webui.ipfs'>} + */ +export async function getDeploymentEnv () { + try { + const response = await fetch('/webui', { method: 'HEAD' }) + if (response.redirected) { + /** + * @see https://github.com/ipfs/kubo/blob/f54b2bcf6061219f7f481e8660e6707ae3bc3c38/cmd/ipfs/daemon.go#L677 + * @see https://github.com/ipfs/kubo/blob/15093a00116ecf6b550023155f31a33f4bba6403/core/corehttp/webui.go#L57 + */ + return 'kubo' + } + return 'local' + } catch { + return 'webui.ipfs' + } +} diff --git a/tsconfig.json b/tsconfig.json index 96138b261..5c1fa924a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -72,5 +72,6 @@ "src/lib/count-dirs.js", "src/lib/sort.js", "src/lib/files.js", + "src/**/*.js" ] } From c2fbccc28ef58609bbd94c750719b18f75afa894 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:15:34 -0800 Subject: [PATCH 2/9] fix: check origin for deploymentEnv first --- src/env.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/env.js b/src/env.js index 9820bc7ab..6e6027068 100644 --- a/src/env.js +++ b/src/env.js @@ -1,9 +1,17 @@ /** * @see https://github.com/ipfs/ipfs-webui/issues/2078#issuecomment-1384444232 + * @see https://github.com/ipfs/ipfs-webui/issues/2078#issuecomment-1384605253 * @returns {Promise<'local'|'kubo'|'webui.ipfs'>} */ export async function getDeploymentEnv () { + const origin = globalThis.location.origin + if (origin.includes('webui-ipfs') || origin.includes('webui.ipfs')) { + if (origin.includes('localhost')) { + return 'local' + } + return 'webui.ipfs' + } try { const response = await fetch('/webui', { method: 'HEAD' }) if (response.redirected) { From f9d9c523daebde7bf8b5aab6b996fd9b18fb6cc2 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:34:44 -0800 Subject: [PATCH 3/9] fix: dont typecheck everything yet.. --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 5c1fa924a..da2376292 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -72,6 +72,6 @@ "src/lib/count-dirs.js", "src/lib/sort.js", "src/lib/files.js", - "src/**/*.js" + "src/env.js" ] } From d15e1b7ad45071c39bddb9d4d40619012b062b6b Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Thu, 26 Jan 2023 16:33:53 -0800 Subject: [PATCH 4/9] fix: use countly.ipfs.tech url --- src/bundles/analytics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundles/analytics.js b/src/bundles/analytics.js index 6f436e253..eb9cca9e4 100644 --- a/src/bundles/analytics.js +++ b/src/bundles/analytics.js @@ -284,7 +284,7 @@ const actions = { } const createAnalyticsBundle = ({ - countlyUrl = 'https://countly.ipfs.io', + countlyUrl = 'https://countly.ipfs.tech', appVersion = process.env.REACT_APP_VERSION, // @ts-ignore - declared but never used appGitRevision = process.env.REACT_APP_GIT_REV, From d9d18b8adbc7b727f4d8db2311d3f4e30f99496f Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Thu, 26 Jan 2023 16:34:58 -0800 Subject: [PATCH 5/9] fix: analytics tests succeed --- src/bundles/analytics.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bundles/analytics.js b/src/bundles/analytics.js index eb9cca9e4..45e63c4ec 100644 --- a/src/bundles/analytics.js +++ b/src/bundles/analytics.js @@ -317,7 +317,10 @@ const createAnalyticsBundle = ({ Countly.require_consent = true Countly.url = countlyUrl - Countly.app_key = await pickAppKey() + const countlyAppKeyPromise = pickAppKey() + countlyAppKeyPromise.then((appKey) => { + Countly.app_key = appKey + }) Countly.app_version = appVersion Countly.debug = debug @@ -357,6 +360,7 @@ const createAnalyticsBundle = ({ // Fix for storybook error 'Countly.init is not a function' if (typeof Countly.init === 'function') { + await countlyAppKeyPromise Countly.init() } }, From b734ab5d8ff2d20ed332d8d36159ebcf47797b34 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Thu, 26 Jan 2023 16:35:34 -0800 Subject: [PATCH 6/9] fix(env.js): use regex for string matching --- src/env.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/env.js b/src/env.js index 6e6027068..3a0222739 100644 --- a/src/env.js +++ b/src/env.js @@ -4,10 +4,13 @@ * @see https://github.com/ipfs/ipfs-webui/issues/2078#issuecomment-1384605253 * @returns {Promise<'local'|'kubo'|'webui.ipfs'>} */ + +const webuiRegex = /(?:webui-ipfs|webui\.ipfs)/ +const localhostRegex = /localhost/ export async function getDeploymentEnv () { - const origin = globalThis.location.origin - if (origin.includes('webui-ipfs') || origin.includes('webui.ipfs')) { - if (origin.includes('localhost')) { + const { origin } = globalThis.location + if (webuiRegex.test(origin)) { + if (localhostRegex.test(origin)) { return 'local' } return 'webui.ipfs' From e1f029618af53662884f01e9e5c0b4d450d0ff09 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:37:43 -0800 Subject: [PATCH 7/9] chore(env.js): add tests --- package-lock.json | 608 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + src/env.js | 16 +- src/env.test.js | 49 ++++ 4 files changed, 665 insertions(+), 9 deletions(-) create mode 100644 src/env.test.js diff --git a/package-lock.json b/package-lock.json index 18a96ebea..96ad63218 100644 --- a/package-lock.json +++ b/package-lock.json @@ -106,6 +106,7 @@ "@storybook/store": "^6.5.9", "@storybook/test-runner": "^0.7.0", "@svgr/cli": "^5.4.0", + "@types/jest": "^29.4.0", "@types/node": "^14.0.27", "@types/path-browserify": "^1.0.0", "@typescript-eslint/eslint-plugin": "^5.30.7", @@ -17175,6 +17176,351 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jest": { + "version": "29.4.0", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.4.0.tgz", + "integrity": "sha512-VaywcGQ9tPorCX/Jkkni7RWGFfI11whqzs8dvxF41P17Z+z872thvEvlIbznjPJ02kl1HMX3LmLOonsj2n7HeQ==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/jest/node_modules/@jest/expect-utils": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.1.tgz", + "integrity": "sha512-w6YJMn5DlzmxjO00i9wu2YSozUYRBhIoJ6nQwpMYcBMtiqMGJm1QBzOf6DDgRao8dbtpDoaqLg6iiQTvv0UHhQ==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.2.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/@jest/schemas": { + "version": "29.4.0", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.0.tgz", + "integrity": "sha512-0E01f/gOZeNTG76i5eWWSupvSHaIINrTie7vCyjiYFKgzNdyEGd12BUv4oNBFHOqlHDbtoJi3HrQ38KCC90NsQ==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.25.16" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/@jest/types": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.1.tgz", + "integrity": "sha512-zbrAXDUOnpJ+FMST2rV7QZOgec8rskg2zv8g2ajeqitp4tvZiyqTCYXANrKsM+ryj5o+LI+ZN2EgU9drrkiwSA==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.4.0", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/@sinclair/typebox": { + "version": "0.25.21", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.21.tgz", + "integrity": "sha512-gFukHN4t8K4+wVC+ECqeqwzBDeFeTzBXroBTqE6vcWrQGbEUpHO7LYdG0f4xnvYq4VOEwITSlHlp0JBAIFMS/g==", + "dev": true + }, + "node_modules/@types/jest/node_modules/@types/yargs": { + "version": "17.0.20", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.20.tgz", + "integrity": "sha512-eknWrTHofQuPk2iuqDm1waA7V6xPlbgBoaaXEgYkClhLOnB0TtbW+srJaOToAgawPxPlHQzwypFA2bhZaUGP5A==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/jest/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@types/jest/node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@types/jest/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@types/jest/node_modules/ci-info": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.7.1.tgz", + "integrity": "sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, + "node_modules/@types/jest/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@types/jest/node_modules/diff-sequences": { + "version": "29.3.1", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.3.1.tgz", + "integrity": "sha512-hlM3QR272NXCi4pq+N4Kok4kOp6EsgOM3ZSpJI7Da3UAs+Ttsi8MRmB6trM/lhyzUxGfOgnpkHtgqm5Q/CTcfQ==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/expect": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.4.1.tgz", + "integrity": "sha512-OKrGESHOaMxK3b6zxIq9SOW8kEXztKff/Dvg88j4xIJxur1hspEbedVkR3GpHe5LO+WB2Qw7OWN0RMTdp6as5A==", + "dev": true, + "dependencies": { + "@jest/expect-utils": "^29.4.1", + "jest-get-type": "^29.2.0", + "jest-matcher-utils": "^29.4.1", + "jest-message-util": "^29.4.1", + "jest-util": "^29.4.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@types/jest/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@types/jest/node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/@types/jest/node_modules/jest-diff": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.1.tgz", + "integrity": "sha512-uazdl2g331iY56CEyfbNA0Ut7Mn2ulAG5vUaEHXycf1L6IPyuImIxSz4F0VYBKi7LYIuxOwTZzK3wh5jHzASMw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.3.1", + "jest-get-type": "^29.2.0", + "pretty-format": "^29.4.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/jest-get-type": { + "version": "29.2.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.2.0.tgz", + "integrity": "sha512-uXNJlg8hKFEnDgFsrCjznB+sTxdkuqiCL6zMgA75qEbAJjJYTs9XPrvDctrEig2GDow22T/LvHgO57iJhXB/UA==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/jest-matcher-utils": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.1.tgz", + "integrity": "sha512-k5h0u8V4nAEy6lSACepxL/rw78FLDkBnXhZVgFneVpnJONhb2DhZj/Gv4eNe+1XqQ5IhgUcqj745UwH0HJmMnA==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.4.1", + "jest-get-type": "^29.2.0", + "pretty-format": "^29.4.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/jest-message-util": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.1.tgz", + "integrity": "sha512-H4/I0cXUaLeCw6FM+i4AwCnOwHRgitdaUFOdm49022YD5nfyr8C/DrbXOBEyJaj+w/y0gGJ57klssOaUiLLQGQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.4.1", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.4.1", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/jest-util": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.1.tgz", + "integrity": "sha512-bQy9FPGxVutgpN4VRc0hk6w7Hx/m6L53QxpDreTZgJd9gfx/AV2MjyPde9tGyZRINAUrSv57p2inGBu2dRLmkQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.4.1", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/@types/jest/node_modules/pretty-format": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.1.tgz", + "integrity": "sha512-dt/Z761JUVsrIKaY215o1xQJBGlSmTx/h4cSqXqjHLnU1+Kt+mavVE7UgqJJO5ukx5HjSswHfmXz4LjS2oIJfg==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.4.0", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@types/jest/node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@types/jest/node_modules/react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true + }, + "node_modules/@types/jest/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@types/jest/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@types/jest/node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -82767,6 +83113,268 @@ "@types/istanbul-lib-report": "*" } }, + "@types/jest": { + "version": "29.4.0", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.4.0.tgz", + "integrity": "sha512-VaywcGQ9tPorCX/Jkkni7RWGFfI11whqzs8dvxF41P17Z+z872thvEvlIbznjPJ02kl1HMX3LmLOonsj2n7HeQ==", + "dev": true, + "requires": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + }, + "dependencies": { + "@jest/expect-utils": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.1.tgz", + "integrity": "sha512-w6YJMn5DlzmxjO00i9wu2YSozUYRBhIoJ6nQwpMYcBMtiqMGJm1QBzOf6DDgRao8dbtpDoaqLg6iiQTvv0UHhQ==", + "dev": true, + "requires": { + "jest-get-type": "^29.2.0" + } + }, + "@jest/schemas": { + "version": "29.4.0", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.0.tgz", + "integrity": "sha512-0E01f/gOZeNTG76i5eWWSupvSHaIINrTie7vCyjiYFKgzNdyEGd12BUv4oNBFHOqlHDbtoJi3HrQ38KCC90NsQ==", + "dev": true, + "requires": { + "@sinclair/typebox": "^0.25.16" + } + }, + "@jest/types": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.1.tgz", + "integrity": "sha512-zbrAXDUOnpJ+FMST2rV7QZOgec8rskg2zv8g2ajeqitp4tvZiyqTCYXANrKsM+ryj5o+LI+ZN2EgU9drrkiwSA==", + "dev": true, + "requires": { + "@jest/schemas": "^29.4.0", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + } + }, + "@sinclair/typebox": { + "version": "0.25.21", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.21.tgz", + "integrity": "sha512-gFukHN4t8K4+wVC+ECqeqwzBDeFeTzBXroBTqE6vcWrQGbEUpHO7LYdG0f4xnvYq4VOEwITSlHlp0JBAIFMS/g==", + "dev": true + }, + "@types/yargs": { + "version": "17.0.20", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.20.tgz", + "integrity": "sha512-eknWrTHofQuPk2iuqDm1waA7V6xPlbgBoaaXEgYkClhLOnB0TtbW+srJaOToAgawPxPlHQzwypFA2bhZaUGP5A==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "ci-info": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.7.1.tgz", + "integrity": "sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w==", + "dev": true + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "diff-sequences": { + "version": "29.3.1", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.3.1.tgz", + "integrity": "sha512-hlM3QR272NXCi4pq+N4Kok4kOp6EsgOM3ZSpJI7Da3UAs+Ttsi8MRmB6trM/lhyzUxGfOgnpkHtgqm5Q/CTcfQ==", + "dev": true + }, + "expect": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.4.1.tgz", + "integrity": "sha512-OKrGESHOaMxK3b6zxIq9SOW8kEXztKff/Dvg88j4xIJxur1hspEbedVkR3GpHe5LO+WB2Qw7OWN0RMTdp6as5A==", + "dev": true, + "requires": { + "@jest/expect-utils": "^29.4.1", + "jest-get-type": "^29.2.0", + "jest-matcher-utils": "^29.4.1", + "jest-message-util": "^29.4.1", + "jest-util": "^29.4.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "jest-diff": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.1.tgz", + "integrity": "sha512-uazdl2g331iY56CEyfbNA0Ut7Mn2ulAG5vUaEHXycf1L6IPyuImIxSz4F0VYBKi7LYIuxOwTZzK3wh5jHzASMw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "diff-sequences": "^29.3.1", + "jest-get-type": "^29.2.0", + "pretty-format": "^29.4.1" + } + }, + "jest-get-type": { + "version": "29.2.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.2.0.tgz", + "integrity": "sha512-uXNJlg8hKFEnDgFsrCjznB+sTxdkuqiCL6zMgA75qEbAJjJYTs9XPrvDctrEig2GDow22T/LvHgO57iJhXB/UA==", + "dev": true + }, + "jest-matcher-utils": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.1.tgz", + "integrity": "sha512-k5h0u8V4nAEy6lSACepxL/rw78FLDkBnXhZVgFneVpnJONhb2DhZj/Gv4eNe+1XqQ5IhgUcqj745UwH0HJmMnA==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "jest-diff": "^29.4.1", + "jest-get-type": "^29.2.0", + "pretty-format": "^29.4.1" + } + }, + "jest-message-util": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.1.tgz", + "integrity": "sha512-H4/I0cXUaLeCw6FM+i4AwCnOwHRgitdaUFOdm49022YD5nfyr8C/DrbXOBEyJaj+w/y0gGJ57klssOaUiLLQGQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.4.1", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.4.1", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + } + }, + "jest-util": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.1.tgz", + "integrity": "sha512-bQy9FPGxVutgpN4VRc0hk6w7Hx/m6L53QxpDreTZgJd9gfx/AV2MjyPde9tGyZRINAUrSv57p2inGBu2dRLmkQ==", + "dev": true, + "requires": { + "@jest/types": "^29.4.1", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + } + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "pretty-format": { + "version": "29.4.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.1.tgz", + "integrity": "sha512-dt/Z761JUVsrIKaY215o1xQJBGlSmTx/h4cSqXqjHLnU1+Kt+mavVE7UgqJJO5ukx5HjSswHfmXz4LjS2oIJfg==", + "dev": true, + "requires": { + "@jest/schemas": "^29.4.0", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true + } + } + }, + "react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + } + } + }, "@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", diff --git a/package.json b/package.json index 8a7da30f2..82bba1eb4 100644 --- a/package.json +++ b/package.json @@ -135,6 +135,7 @@ "@storybook/store": "^6.5.9", "@storybook/test-runner": "^0.7.0", "@svgr/cli": "^5.4.0", + "@types/jest": "^29.4.0", "@types/node": "^14.0.27", "@types/path-browserify": "^1.0.0", "@typescript-eslint/eslint-plugin": "^5.30.7", diff --git a/src/env.js b/src/env.js index 3a0222739..7d3c1f933 100644 --- a/src/env.js +++ b/src/env.js @@ -1,4 +1,3 @@ - /** * @see https://github.com/ipfs/ipfs-webui/issues/2078#issuecomment-1384444232 * @see https://github.com/ipfs/ipfs-webui/issues/2078#issuecomment-1384605253 @@ -6,26 +5,25 @@ */ const webuiRegex = /(?:webui-ipfs|webui\.ipfs)/ -const localhostRegex = /localhost/ +const localhostRegex = /(?:localhost|127.0.0.1)/ +const ipfsRegex = /ipfs/ export async function getDeploymentEnv () { const { origin } = globalThis.location if (webuiRegex.test(origin)) { - if (localhostRegex.test(origin)) { - return 'local' - } - return 'webui.ipfs' + return localhostRegex.test(origin) ? 'local' : 'webui.ipfs' } try { const response = await fetch('/webui', { method: 'HEAD' }) - if (response.redirected) { + const { pathname } = new URL(response.url) + if (response.redirected && ipfsRegex.test(pathname)) { /** * @see https://github.com/ipfs/kubo/blob/f54b2bcf6061219f7f481e8660e6707ae3bc3c38/cmd/ipfs/daemon.go#L677 * @see https://github.com/ipfs/kubo/blob/15093a00116ecf6b550023155f31a33f4bba6403/core/corehttp/webui.go#L57 */ return 'kubo' } - return 'local' } catch { - return 'webui.ipfs' + // dont throw from this method } + return localhostRegex.test(origin) ? 'local' : 'webui.ipfs' } diff --git a/src/env.test.js b/src/env.test.js new file mode 100644 index 000000000..320b67126 --- /dev/null +++ b/src/env.test.js @@ -0,0 +1,49 @@ +/* global describe, it, expect, afterEach, jest */ +// @ts-check +import { getDeploymentEnv } from './env' + +describe('env.js', function () { + describe('getDeploymentEnv', function () { + const fetchMock = jest.fn() + function testOriginAndEnv (url, fetchImpl, expectedEnv, numberOfFetchCalls) { + it(`${url} returns env ${expectedEnv}`, async () => { + const { origin } = new URL(url) + // @ts-expect-error + jest.spyOn(globalThis, 'location', 'get').mockReturnValue({ origin }) + fetchMock.mockImplementation(fetchImpl) + expect(await getDeploymentEnv()).toBe(expectedEnv) + expect(fetchMock.mock.calls.length).toBe(numberOfFetchCalls) + }) + } + globalThis.fetch = fetchMock + + afterEach(function () { + jest.clearAllMocks() + }) + /** + * webui.ipfs deployed endpoints + */ + testOriginAndEnv('https://webui.ipfs.io', () => {}, 'webui.ipfs', 0) + testOriginAndEnv('https://webui-ipfs-io.ipns.dweb.link/', () => {}, 'webui.ipfs', 0) + testOriginAndEnv('https://webui.ipfs.tech', () => {}, 'webui.ipfs', 0) + testOriginAndEnv('https://some-random-url', () => { throw new Error('no match on origin') }, 'webui.ipfs', 1) + testOriginAndEnv('https://some-random-url', () => ({ redirected: false, url: 'https://some-random-url/webui' }), 'webui.ipfs', 1) + + /** + * local webui endpoints + */ + testOriginAndEnv('http://webui.ipfs.io.ipns.localhost:8080/', () => {}, 'local', 0) + testOriginAndEnv('http://webui-ipfs.io.ipns.localhost:8080/', () => {}, 'local', 0) + testOriginAndEnv('http://webui.ipfs.io.ipns.localhost:48080/', () => {}, 'local', 0) // brave + testOriginAndEnv('http://localhost:3000/', () => { throw new Error('no match on origin') }, 'local', 1) + testOriginAndEnv('http://127.0.0.1:3000/', () => { throw new Error('no match on origin') }, 'local', 1) + testOriginAndEnv('https://some-random-url.localhost:3333', () => ({ redirected: false, url: 'https://some-random-url.localhost:3333/webui' }), 'local', 1) + + /** + * Kubo webui endpoints + */ + testOriginAndEnv('http://localhost:5001/webui', () => ({ redirected: true, url: 'http://localhost:5001/ipfs/bafybeiequgo72mrvuml56j4gk7crewig5bavumrrzhkqbim6b3s2yqi7ty/' }), 'kubo', 1) + testOriginAndEnv('http://127.0.0.1:5002/webui', () => ({ redirected: true, url: 'http://127.0.0.1:5002/ipfs/bafybeiequgo72mrvuml56j4gk7crewig5bavumrrzhkqbim6b3s2yqi7ty/' }), 'kubo', 1) + testOriginAndEnv('https://some-random-url.localhost:3333', () => ({ redirected: true, url: 'https://some-random-url.localhost:3333/ipfs/bafybeiequgo72mrvuml56j4gk7crewig5bavumrrzhkqbim6b3s2yqi7ty/' }), 'kubo', 1) + }) +}) From 364dcba677c8bd623a208cc73f16c615b0cc90ce Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:46:01 -0800 Subject: [PATCH 8/9] chore(env.test.js): reset globalThis.fetch completely when done --- src/env.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/env.test.js b/src/env.test.js index 320b67126..602271ac2 100644 --- a/src/env.test.js +++ b/src/env.test.js @@ -15,11 +15,17 @@ describe('env.js', function () { expect(fetchMock.mock.calls.length).toBe(numberOfFetchCalls) }) } - globalThis.fetch = fetchMock + const originalFetch = globalThis.fetch + beforeAll(() => { + globalThis.fetch = fetchMock + }) afterEach(function () { jest.clearAllMocks() }) + afterAll(() => { + globalThis.fetch = originalFetch + }) /** * webui.ipfs deployed endpoints */ From 827c13acbebb7bf66a91133745fc8f0daf7287fd Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Thu, 26 Jan 2023 19:02:10 -0800 Subject: [PATCH 9/9] chore: address pr comments --- src/bundles/analytics.js | 14 +++++++------- src/env.js | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bundles/analytics.js b/src/bundles/analytics.js index 45e63c4ec..4f3f6e123 100644 --- a/src/bundles/analytics.js +++ b/src/bundles/analytics.js @@ -108,15 +108,15 @@ const COUNTLY_KEY_WEBUI_KUBO = 'c4524cc93fed92a5838d4ea27c5a65526b4e7558' async function pickAppKey () { const isProd = process.env.NODE_ENV === 'production' - if (root.ipfsDesktop && root.ipfsDesktop.countlyAppKey) { + if (root.ipfsDesktop?.countlyAppKey) { return root.ipfsDesktop.countlyAppKey - } else { - const env = await getDeploymentEnv() - if (env === 'kubo') { - return COUNTLY_KEY_WEBUI_KUBO - } - return isProd ? COUNTLY_KEY_WEBUI : COUNTLY_KEY_WEBUI_TEST } + + const env = await getDeploymentEnv() + if (env === 'kubo') { + return COUNTLY_KEY_WEBUI_KUBO + } + return isProd ? COUNTLY_KEY_WEBUI : COUNTLY_KEY_WEBUI_TEST } const consentGroups = { diff --git a/src/env.js b/src/env.js index 7d3c1f933..946fc7e6e 100644 --- a/src/env.js +++ b/src/env.js @@ -4,7 +4,7 @@ * @returns {Promise<'local'|'kubo'|'webui.ipfs'>} */ -const webuiRegex = /(?:webui-ipfs|webui\.ipfs)/ +const webuiRegex = /webui[-.]ipfs/ const localhostRegex = /(?:localhost|127.0.0.1)/ const ipfsRegex = /ipfs/ export async function getDeploymentEnv () {