mirror of
https://github.com/tooot-app/app
synced 2024-12-22 15:49:42 +01:00
Fix card url matching regex
This commit is contained in:
parent
96497aad25
commit
17d4245cd9
@ -30,18 +30,24 @@ const matchAccount = (
|
|||||||
// https://social.xmflsct.com/web/accounts/14195 <- default
|
// https://social.xmflsct.com/web/accounts/14195 <- default
|
||||||
// https://social.xmflsct.com/web/@tooot <- pretty ! cannot be searched on the same instance
|
// https://social.xmflsct.com/web/@tooot <- pretty ! cannot be searched on the same instance
|
||||||
// https://social.xmflsct.com/@tooot <- pretty
|
// https://social.xmflsct.com/@tooot <- pretty
|
||||||
const matcherAccount = new RegExp(/(https?:\/\/)?([^\/]+)(\/web|\/web\/accounts)?\/([0-9]+|@.+)/)
|
const matcherAccount = new RegExp(
|
||||||
|
/(https?:\/\/)?([^\/]+)(\/web\/accounts\/([0-9]+)|\/web\/(@.+)|\/(@.+))/
|
||||||
|
)
|
||||||
|
|
||||||
const matched = url.match(matcherAccount)
|
const matched = url.match(matcherAccount)
|
||||||
if (matched) {
|
if (matched) {
|
||||||
const hostname = matched[2]
|
const hostname = matched[2]
|
||||||
const style = matched[4].startsWith('@') ? 'pretty' : 'default'
|
const account = matched.filter(i => i).reverse()?.[0]
|
||||||
const account = matched[4]
|
if (account) {
|
||||||
|
const style = account.startsWith('@') ? 'pretty' : 'default'
|
||||||
|
|
||||||
const instanceUrl = getInstanceUrl(store.getState())
|
const instanceUrl = getInstanceUrl(store.getState())
|
||||||
return style === 'default'
|
return style === 'default'
|
||||||
? { id: account, style, sameInstance: hostname === instanceUrl }
|
? { id: account, style, sameInstance: hostname === instanceUrl }
|
||||||
: { username: account, style, sameInstance: hostname === instanceUrl }
|
: { username: account, style, sameInstance: hostname === instanceUrl }
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
Loading…
Reference in New Issue
Block a user