diff --git a/src/pages/files/Download.tsx b/src/pages/files/Download.tsx index 7970cfc6..73f3b84e 100644 --- a/src/pages/files/Download.tsx +++ b/src/pages/files/Download.tsx @@ -8,7 +8,7 @@ import { History } from '../../components/History' import { Context, defaultUploadOrigin } from '../../providers/File' import { Context as SettingsContext } from '../../providers/Settings' import { ROUTES } from '../../routes' -import { recognizeEnsOrSwarmHash } from '../../utils' +import { recognizeEnsOrSwarmHash, regexpEns } from '../../utils' import { determineHistoryName, HISTORY_KEYS, putHistory } from '../../utils/local-storage' import { FileNavigation } from './FileNavigation' @@ -23,10 +23,17 @@ export function Download(): ReactElement { const navigate = useNavigate() const validateChange = (value: string) => { - if (Utils.isHexString(value, 64) || Utils.isHexString(value, 128) || !value.trim().length) { + if ( + Utils.isHexString(value, 64) || + Utils.isHexString(value, 128) || + !value.trim().length || + regexpEns.test(value) + ) { setReferenceError(undefined) } else { - setReferenceError('Incorrect format of swarm hash. Expected 64 or 128 hexstring characters.') + setReferenceError( + 'Incorrect format of swarm hash. Expected 64 or 128 hexstring characters, bzz.link url or ENS domain.', + ) } } diff --git a/src/utils/index.ts b/src/utils/index.ts index 9e7a86a5..78a3d75e 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -145,7 +145,7 @@ export function extractSwarmCid(s: string): string | undefined { // Matches any number of subdomains ending with .eth // e.g. this.is.just-a-test.eth -const regexpEns = /((?:(?!-)[a-z0-9-]{1,63}(?