From dcb24382fc3cf6a60faa92a74fd9a05bc488d164 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 19 Apr 2023 10:42:26 +0800 Subject: [PATCH] Fix instance url Why do I need to keep doing this --- src/components/shortcuts-settings.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/shortcuts-settings.jsx b/src/components/shortcuts-settings.jsx index 3f6ee94b..70698435 100644 --- a/src/components/shortcuts-settings.jsx +++ b/src/components/shortcuts-settings.jsx @@ -523,6 +523,14 @@ function ShortcutForm({ const result = {}; data.forEach((value, key) => { result[key] = value?.trim(); + if (key === 'instance') { + // Remove protocol and trailing slash + result[key] = result[key] + .replace(/^https?:\/\//, '') + .replace(/\/+$/, ''); + // Remove @acct@ or acct@ from instance URL + result[key] = result[key].replace(/^@?[^@]+@/, ''); + } }); console.log('result', result); if (!result.type) return;