correct and suggest uris for publish on search

This commit is contained in:
jessop 2019-12-16 16:33:17 -05:00
parent c9fd7f032c
commit 83facb16c6
3 changed files with 20 additions and 13 deletions

View file

@ -922,11 +922,14 @@
"The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.": "The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.", "The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.": "The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.",
"Provide a description and link to your license": "Provide a description and link to your license", "Provide a description and link to your license": "Provide a description and link to your license",
"Wallet servers": "Wallet servers", "Wallet servers": "Wallet servers",
"In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.": "In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.",
"Followers": "Followers", "Followers": "Followers",
"%number% files hidden due to your %content_viewing_preferences_link%": "%number% files hidden due to your %content_viewing_preferences_link%", "%number% files hidden due to your %content_viewing_preferences_link%": "%number% files hidden due to your %content_viewing_preferences_link%",
"Use official lbry.tv wallet servers": "Use official lbry.tv wallet servers", "Use official lbry.tv wallet servers": "Use official lbry.tv wallet servers",
"Use custom wallet servers": "Use custom wallet servers", "Use custom wallet servers": "Use custom wallet servers",
"Remove custom wallet server": "Remove custom wallet server", "Remove custom wallet server": "Remove custom wallet server",
"Add": "Add" "Add": "Add",
"In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.": "In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.",
"lbry.tv": "lbry.tv",
"Your Blocked Channels": "Your Blocked Channels",
"Bid position must be a number.": "Bid position must be a number."
} }

View file

@ -54,8 +54,8 @@ function PublishFile(props: Props) {
}; };
// Strip off extention and replace invalid characters // Strip off extention and replace invalid characters
let fileName = file.name.substr(0, file.name.lastIndexOf('.')) || file.name; let fileName = file.name.substr(0, file.name.lastIndexOf('.')) || file.name;
let replaceChars = new RegExp(regexInvalidURI, 'gu'); let INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu');
let parsedFileName = fileName.replace(replaceChars, '-'); let parsedFileName = fileName.replace(INVALID_URI_CHARS, '-');
if (!isStillEditing) { if (!isStillEditing) {
publishFormParams.name = parsedFileName; publishFormParams.name = parsedFileName;
} }

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
import React, { useEffect, Fragment } from 'react'; import React, { useEffect, Fragment } from 'react';
import { isURIValid, normalizeURI } from 'lbry-redux'; import { isURIValid, normalizeURI, regexInvalidURI } 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';
@ -22,12 +22,16 @@ export default function SearchPage(props: Props) {
const { search, uris, onFeedbackPositive, onFeedbackNegative, location, isSearching } = props; const { search, uris, onFeedbackPositive, onFeedbackNegative, location, isSearching } = props;
const urlParams = new URLSearchParams(location.search); const urlParams = new URLSearchParams(location.search);
const urlQuery = urlParams.get('q'); const urlQuery = urlParams.get('q');
const isValid = isURIValid(urlQuery);
let uri; let INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu');
if (isValid) { let modifiedUrlQuery = urlQuery
uri = normalizeURI(urlQuery); ? urlQuery
} .trim()
.replace(/\s+/, '-')
.replace(INVALID_URI_CHARS, '')
: '';
const isModifiedUriValid = isURIValid(modifiedUrlQuery);
const normalizedModifiedUri = isModifiedUriValid && normalizeURI(modifiedUrlQuery);
useEffect(() => { useEffect(() => {
if (urlQuery) { if (urlQuery) {
@ -40,11 +44,11 @@ export default function SearchPage(props: Props) {
<section className="search"> <section className="search">
{urlQuery && ( {urlQuery && (
<Fragment> <Fragment>
{isValid && ( {isModifiedUriValid && (
<header className="search__header"> <header className="search__header">
<ClaimUri uri={uri} /> <ClaimUri uri={normalizedModifiedUri} />
<div className="card"> <div className="card">
<ClaimPreview uri={uri} type="large" placeholder="publish" /> <ClaimPreview uri={normalizedModifiedUri} type="large" placeholder="publish" />
</div> </div>
</header> </header>
)} )}