toLowerCase() all the instance URLs!

This commit is contained in:
Lim Chee Aun 2023-01-01 20:59:55 +08:00
parent bfaefbe178
commit 727b944f3b
3 changed files with 7 additions and 7 deletions

View file

@ -82,7 +82,7 @@ function App() {
let account = accounts.find((a) => a.info.id === mastoAccount.id);
if (account) {
account.info = mastoAccount;
account.instanceURL = instanceURL;
account.instanceURL = instanceURL.toLowerCase();
account.accessToken = accessToken;
} else {
account = {
@ -166,7 +166,7 @@ function App() {
console.log(info);
const { uri, domain } = info;
const instances = store.local.getJSON('instances') || {};
instances[domain || uri] = info;
instances[(domain || uri).toLowerCase()] = info;
store.local.setJSON('instances', instances);
})();
});

View file

@ -73,9 +73,9 @@ function Compose({
const configuration = useMemo(() => {
try {
const instances = store.local.getJSON('instances');
const currentInstance = accounts.find(
(a) => a.info.id === currentAccount,
).instanceURL;
const currentInstance = accounts
.find((a) => a.info.id === currentAccount)
.instanceURL.toLowerCase();
const config = instances[currentInstance].configuration;
console.log(config);
return config;

View file

@ -16,14 +16,14 @@ function Login() {
useEffect(() => {
if (cachedInstanceURL) {
instanceURLRef.current.value = cachedInstanceURL;
instanceURLRef.current.value = cachedInstanceURL.toLowerCase();
}
}, []);
const onSubmit = (e) => {
e.preventDefault();
const { elements } = e.target;
let instanceURL = elements.instanceURL.value;
let instanceURL = elements.instanceURL.value.toLowerCase();
// Remove protocol from instance URL
instanceURL = instanceURL.replace(/(^\w+:|^)\/\//, '');
store.local.set('instanceURL', instanceURL);