Merge pull request #3386 from lbryio/feat-suggestedPublishUris

correct and suggest uris for publish on search
This commit is contained in:
jessopb 2019-12-17 15:38:59 -05:00 committed by GitHub
commit 5c07f412ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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.",
"Provide a description and link to your license": "Provide a description and link to your license",
"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",
"%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 custom wallet servers": "Use custom wallet servers",
"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
let fileName = file.name.substr(0, file.name.lastIndexOf('.')) || file.name;
let replaceChars = new RegExp(regexInvalidURI, 'gu');
let parsedFileName = fileName.replace(replaceChars, '-');
let INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu');
let parsedFileName = fileName.replace(INVALID_URI_CHARS, '-');
if (!isStillEditing) {
publishFormParams.name = parsedFileName;
}

View file

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