From 8f407a36d46aaeef34c22a9cc133eadafa6ba582 Mon Sep 17 00:00:00 2001 From: ioancole Date: Sat, 5 Sep 2020 10:57:40 +0800 Subject: [PATCH] Hiding URIs header for invalid URIs --- ui/page/search/view.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/page/search/view.jsx b/ui/page/search/view.jsx index 674ef4e80..86f5f7f57 100644 --- a/ui/page/search/view.jsx +++ b/ui/page/search/view.jsx @@ -3,7 +3,7 @@ import { SIMPLE_SITE, SHOW_ADS } from 'config'; import * as ICONS from 'constants/icons'; import * as PAGES from 'constants/pages'; import React, { useEffect, Fragment } from 'react'; -import { Lbry, regexInvalidURI, parseURI } from 'lbry-redux'; +import { Lbry, regexInvalidURI, parseURI, isNameValid } from 'lbry-redux'; import ClaimPreview from 'component/claimPreview'; import ClaimList from 'component/claimList'; import Page from 'component/page'; @@ -50,11 +50,13 @@ export default function SearchPage(props: Props) { } const INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu'); - let isValid = false; let path; + let isValid = true; try { - ({ path } = parseURI(urlQuery.replace(/ /g, '-').replace(/:/g, '#'))); - isValid = true; + let { streamName } = parseURI(urlQuery.replace(/ /g, '-').replace(/:/g, '#')); + if (!isNameValid(streamName)) { + isValid = false; + } } catch (e) { isValid = false; } @@ -94,7 +96,7 @@ export default function SearchPage(props: Props) {
{urlQuery && ( - {!SIMPLE_SITE && ( + {!SIMPLE_SITE && isValid && (