fix: add url name filtering to mini-portfolio (#6231)
* fix: add url name filtering to mini-portfolio * Update src/components/WalletDropdown/MiniPortfolio/Pools/index.tsx Co-authored-by: cartcrom <39385577+cartcrom@users.noreply.github.com> * fix: remove unused deps (#6227) * init * remove one more useless dep * bump up test size * bump up test size * up size * fix lint and add str == undefined case to hasURL --------- Co-authored-by: cartcrom <39385577+cartcrom@users.noreply.github.com> Co-authored-by: lynn <41491154+lynnshaoyu@users.noreply.github.com>
This commit is contained in:
parent
478a05a34f
commit
581c0982db
@ -215,11 +215,7 @@ export default function PositionListItem({
|
|||||||
const removed = liquidity?.eq(0)
|
const removed = liquidity?.eq(0)
|
||||||
|
|
||||||
const containsURL = useMemo(
|
const containsURL = useMemo(
|
||||||
() =>
|
() => [token0?.name, token0?.symbol, token1?.name, token1?.symbol].some((testString) => hasURL(testString)),
|
||||||
[token0?.name, token0?.symbol, token1?.name, token1?.symbol].reduce(
|
|
||||||
(acc, testString) => acc || Boolean(testString && hasURL(testString)),
|
|
||||||
false
|
|
||||||
),
|
|
||||||
[token0?.name, token0?.symbol, token1?.name, token1?.symbol]
|
[token0?.name, token0?.symbol, token1?.name, token1?.symbol]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import { useNavigate } from 'react-router-dom'
|
|||||||
import styled from 'styled-components/macro'
|
import styled from 'styled-components/macro'
|
||||||
import { ThemedText } from 'theme'
|
import { ThemedText } from 'theme'
|
||||||
import { switchChain } from 'utils/switchChain'
|
import { switchChain } from 'utils/switchChain'
|
||||||
|
import { hasURL } from 'utils/urlChecks'
|
||||||
|
|
||||||
import { ExpandoRow } from '../ExpandoRow'
|
import { ExpandoRow } from '../ExpandoRow'
|
||||||
import { PortfolioLogo } from '../PortfolioLogo'
|
import { PortfolioLogo } from '../PortfolioLogo'
|
||||||
@ -98,6 +99,18 @@ function PositionListItem({ positionInfo }: { positionInfo: PositionInfo }) {
|
|||||||
navigate('/pool/' + details.tokenId)
|
navigate('/pool/' + details.tokenId)
|
||||||
}, [walletChainId, chainId, connector, toggleWalletDrawer, navigate, details.tokenId])
|
}, [walletChainId, chainId, connector, toggleWalletDrawer, navigate, details.tokenId])
|
||||||
|
|
||||||
|
const containsURL = useMemo(
|
||||||
|
() =>
|
||||||
|
[pool.token0.name, pool.token0.symbol, pool.token1.name, pool.token1.symbol].some((testString) =>
|
||||||
|
hasURL(testString)
|
||||||
|
),
|
||||||
|
[pool]
|
||||||
|
)
|
||||||
|
|
||||||
|
if (containsURL) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PortfolioRow
|
<PortfolioRow
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export function hasURL(str: string): boolean {
|
export function hasURL(str?: string): boolean {
|
||||||
|
if (!str) return false
|
||||||
const pattern = new RegExp(
|
const pattern = new RegExp(
|
||||||
'([a-zA-Z0-9]+://)?' + // optional protocol
|
'([a-zA-Z0-9]+://)?' + // optional protocol
|
||||||
'([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?' + // optional username:password
|
'([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?' + // optional username:password
|
||||||
|
Loading…
Reference in New Issue
Block a user