Hide search page URI header for invalid channel/stream name
This commit is contained in:
parent
4add1f7200
commit
055a476d2f
1 changed files with 7 additions and 5 deletions
|
@ -3,7 +3,7 @@ import { SIMPLE_SITE, SHOW_ADS } from 'config';
|
||||||
import * as ICONS from 'constants/icons';
|
import * as ICONS from 'constants/icons';
|
||||||
import * as PAGES from 'constants/pages';
|
import * as PAGES from 'constants/pages';
|
||||||
import React, { useEffect, Fragment } from 'react';
|
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 ClaimPreview from 'component/claimPreview';
|
||||||
import ClaimList from 'component/claimList';
|
import ClaimList from 'component/claimList';
|
||||||
import Page from 'component/page';
|
import Page from 'component/page';
|
||||||
|
@ -50,11 +50,13 @@ export default function SearchPage(props: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu');
|
const INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu');
|
||||||
let isValid = false;
|
|
||||||
let path;
|
let path;
|
||||||
|
let isValid = true;
|
||||||
try {
|
try {
|
||||||
({ path } = parseURI(urlQuery.replace(/ /g, '-').replace(/:/g, '#')));
|
let { streamName } = parseURI(urlQuery.replace(/ /g, '-').replace(/:/g, '#'));
|
||||||
isValid = true;
|
if (!isNameValid(streamName)) {
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +96,7 @@ export default function SearchPage(props: Props) {
|
||||||
<section className="search">
|
<section className="search">
|
||||||
{urlQuery && (
|
{urlQuery && (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{!SIMPLE_SITE && (
|
{!SIMPLE_SITE && isValid && (
|
||||||
<header className="search__header">
|
<header className="search__header">
|
||||||
<div className="claim-preview__actions--header">
|
<div className="claim-preview__actions--header">
|
||||||
<ClaimUri uri={uriFromQuery} noShortUrl />
|
<ClaimUri uri={uriFromQuery} noShortUrl />
|
||||||
|
|
Loading…
Reference in a new issue