mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-05-02 05:10:34 +03:00
Still got to make sure instance is lowercase
Also, spellcheck={false} > spellcheck="false"
This commit is contained in:
parent
c95aeaee01
commit
2120a1e28e
4 changed files with 14 additions and 4 deletions
src/utils
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue