From 2120a1e28ebaf496e5fcfd52f60a83c5edd44596 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 22 Feb 2023 09:46:50 +0800 Subject: [PATCH] Still got to make sure instance is lowercase Also, spellcheck={false} > spellcheck="false" --- src/components/shortcuts-settings.jsx | 3 +++ src/pages/login.jsx | 2 +- src/pages/public.jsx | 3 ++- src/utils/api.js | 10 ++++++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/shortcuts-settings.jsx b/src/components/shortcuts-settings.jsx index 84cb01dc..da4af345 100644 --- a/src/components/shortcuts-settings.jsx +++ b/src/components/shortcuts-settings.jsx @@ -368,6 +368,9 @@ function ShortcutForm({ type, lists, followedHashtags, onSubmit, disabled }) { ? 'followed-hashtags-datalist' : null } + autocorrect="off" + autocapitalize="off" + spellcheck={false} /> {currentType === 'hashtag' && followedHashtags.length > 0 && ( diff --git a/src/pages/login.jsx b/src/pages/login.jsx index 5968ffc8..e86aa05c 100644 --- a/src/pages/login.jsx +++ b/src/pages/login.jsx @@ -88,7 +88,7 @@ function Login() { autocorrect="off" autocapitalize="off" autocomplete="off" - spellcheck="false" + spellcheck={false} /> {instancesList.map((instance) => ( diff --git a/src/pages/public.jsx b/src/pages/public.jsx index 8831be08..62bc15a1 100644 --- a/src/pages/public.jsx +++ b/src/pages/public.jsx @@ -79,7 +79,7 @@ function Public({ local, ...props }) { type="button" class="plain" onClick={() => { - const newInstance = prompt( + let newInstance = prompt( 'Enter a new instance e.g. "mastodon.social"', ); if (!/\./.test(newInstance)) { @@ -87,6 +87,7 @@ function Public({ local, ...props }) { return; } if (newInstance) { + newInstance = newInstance.toLowerCase().trim(); navigate(isLocal ? `/${newInstance}/p/l` : `/${newInstance}/p`); } }} diff --git a/src/utils/api.js b/src/utils/api.js index e98836f0..c1b9fda4 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -115,6 +115,11 @@ export async function initPreferences(client) { // Get the masto instance // If accountID is provided, get the masto instance for that account export function api({ instance, accessToken, accountID, account } = {}) { + // Always lowercase and trim the instance + if (instance) { + instance = instance.toLowerCase().trim(); + } + // If instance and accessToken are provided, get the masto instance for that account if (instance && accessToken) { return { @@ -131,7 +136,7 @@ export function api({ instance, accessToken, accountID, account } = {}) { account = account || getAccount(accountID); if (account) { const accessToken = account.accessToken; - const instance = account.instanceURL; + const instance = account.instanceURL.toLowerCase().trim(); return { masto: accountApis[instance]?.[accessToken] || @@ -155,12 +160,13 @@ export function api({ instance, accessToken, accountID, account } = {}) { } // If no instance is provided, get the masto instance for the current account - if (currentAccountApi) + if (currentAccountApi) { return { masto: currentAccountApi, authenticated: true, instance: currentAccountApi.__instance__, }; + } const currentAccount = getCurrentAccount(); if (currentAccount) { const { accessToken, instanceURL: instance } = currentAccount;