fix: connected_account match error

This commit is contained in:
DIYgod
2023-05-10 10:44:24 +01:00
parent ae9b297d32
commit e37adaff30
+21 -2
View File
@@ -53,8 +53,27 @@ export const SiteFooter: React.FC<{
{site?.metadata?.content?.connected_accounts && (
<div className="sm:-mr-5 sm:block inline-block align-middle mr-4">
{site?.metadata?.content?.connected_accounts.map(
(account, index) => {
const match = account.match(/:\/\/account:(.*)@(.*)/)
(
account:
| string
| { uri: string }
| { identity: string; platform: string }
| any, // Otherwise type check will alarm
index,
) => {
let match: RegExpMatchArray | null = null
switch (typeof account) {
case "string":
match = account.match(/:\/\/account:(.*)@(.*)/)
break
case "object":
if (account.uri) {
match = account.uri.match(/:\/\/account:(.*)@(.*)/)
} else if (account.identity && account.platform) {
match = ["", account.identity, account.platform]
}
break
}
if (match) {
return (
<Platform