diff --git a/packages/shared/lib/core/nfts/utils/isFlaggedNft.ts b/packages/shared/lib/core/nfts/utils/isFlaggedNft.ts index 57905d0b2eb..0238cc5a282 100644 --- a/packages/shared/lib/core/nfts/utils/isFlaggedNft.ts +++ b/packages/shared/lib/core/nfts/utils/isFlaggedNft.ts @@ -1,3 +1,4 @@ +import { localize } from '../../i18n' import { INft } from '../interfaces' /** @@ -10,10 +11,13 @@ export function isFlaggedNft(nft: INft): string | undefined { const parsedMetadata = nft.parsedMetadata const parsedName = parsedMetadata?.name ?? '' const parsedDescription = parsedMetadata?.description ?? '' - const urlRegex = /((https?|ftp|file):\/\/)?([\da-z-]+\.)+([a-z]{2,6})([/\w .-]*)*\/?$/gi + const urlRegex = new RegExp( + '\\b(?:https?:\\/\\/)?[a-zA-Z0-9-]+(?:[\\.\\u2024\\uFE52\\uFF0E\\uFF61][a-zA-Z0-9-]+)+\\b(?:[\\/\\?#][^\\s()<>]*)?', + 'i' + ) const containsUrl = urlRegex.test(name) || urlRegex.test(parsedName) || urlRegex.test(parsedDescription) - // Note: in order to avoid issues with the translations, we are using a hardcoded string here - const WARNING_MESSAGE = - 'Be careful when following unknown links. Never share your private keys, nor enter them into any websites or services. ' - return containsUrl ? WARNING_MESSAGE : undefined + + if (containsUrl) { + return localize('warning.nft.flagged') + } } diff --git a/packages/shared/locales/en.json b/packages/shared/locales/en.json index cd1ff100668..1f10a52eef1 100644 --- a/packages/shared/locales/en.json +++ b/packages/shared/locales/en.json @@ -2127,6 +2127,9 @@ }, "participation": { "noFunds": "You do not have any IOTA." + }, + "nft": { + "flagged": "Be careful when following unknown links. Never share your private keys, nor enter them into any websites or services." } }, "tooltips": {