fix: treat matrix links as regular web urls. Closes #3329

This commit is contained in:
Gabe Kangas
2024-01-21 20:22:13 -08:00
parent f9915c9a72
commit 2b57741397
3 changed files with 1 additions and 47 deletions

View File

@@ -52,33 +52,6 @@ export function isValidAccount(account: string, protocol: string): boolean {
return true;
}
/**
* Determines if an account is valid by simply checking for a protocol, username
* and server, delimited by a colon. For example: @username:example.com
* @param {string} account - An account to validate. Example: @me:matrix.org
* @returns {boolean} - True if the account is valid, false otherwise.
*/
export function isValidMatrixAccount(account: string): boolean {
if (account.startsWith('matrix:')) {
// eslint-disable-next-line no-param-reassign
account = account.slice(7);
}
if (account.startsWith('@')) {
// eslint-disable-next-line no-param-reassign
account = account.slice(1);
}
const components = account.split(':');
const [user, host] = components;
if (components.length !== 2 || !user || !host) {
return false;
}
return true;
}
/**
* Determines if a fediverse account is valid.
* For example: @username@example.com