parent
fdc68684ed
commit
0f4bc36bcd
4 changed files with 23 additions and 3 deletions
|
@ -13,6 +13,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
|
|||
* Support markdown makeup in claim description
|
||||
* Replaced free speech flag (used when image is missing) with labeled color tiles
|
||||
* Added a loading message to file actions
|
||||
* URL is auto suggested in Publish Page
|
||||
|
||||
### Changed
|
||||
* Publishes now uses claims rather than files
|
||||
|
|
|
@ -43,6 +43,7 @@ class PublishForm extends React.PureComponent {
|
|||
creatingChannel: false,
|
||||
modal: null,
|
||||
isFee: false,
|
||||
customUrl: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -203,6 +204,9 @@ class PublishForm extends React.PureComponent {
|
|||
|
||||
handleNameChange(event) {
|
||||
var rawName = event.target.value;
|
||||
this.setState({
|
||||
customUrl: Boolean(rawName.length),
|
||||
});
|
||||
|
||||
this.nameChanged(rawName);
|
||||
}
|
||||
|
@ -445,11 +449,24 @@ class PublishForm extends React.PureComponent {
|
|||
onFileChange() {
|
||||
if (this.refs.file.getValue()) {
|
||||
this.setState({ hasFile: true });
|
||||
if (!this.state.customUrl) {
|
||||
let fileName = this._getFileName(this.refs.file.getValue());
|
||||
this.nameChanged(fileName);
|
||||
}
|
||||
} else {
|
||||
this.setState({ hasFile: false });
|
||||
}
|
||||
}
|
||||
|
||||
_getFileName(fileName) {
|
||||
const path = require("path");
|
||||
const extension = path.extname(fileName);
|
||||
|
||||
fileName = path.basename(fileName, extension);
|
||||
fileName = fileName.replace(lbryuri.REGEXP_INVALID_URI, "");
|
||||
return fileName;
|
||||
}
|
||||
|
||||
getNameBidHelpText() {
|
||||
if (this.state.prefillDone) {
|
||||
return __("Existing claim data was prefilled");
|
||||
|
|
|
@ -296,7 +296,7 @@ lbry.formatCredits = function(amount, precision) {
|
|||
lbry.formatName = function(name) {
|
||||
// Converts LBRY name to standard format (all lower case, no special characters, spaces replaced by dashes)
|
||||
name = name.replace("/s+/g", "-");
|
||||
name = name.toLowerCase().replace(/[^a-z0-9\-]/g, "");
|
||||
name = name.toLowerCase().replace(lbryuri.REGEXP_INVALID_URI, "");
|
||||
return name;
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ const CLAIM_ID_MAX_LEN = 40;
|
|||
|
||||
const lbryuri = {};
|
||||
|
||||
lbryuri.REGEXP_INVALID_URI = /[^A-Za-z0-9-]/g;
|
||||
|
||||
/**
|
||||
* Parses a LBRY name into its component parts. Throws errors with user-friendly
|
||||
* messages for invalid names.
|
||||
|
@ -70,7 +72,7 @@ lbryuri.parse = function(uri, requireProto = false) {
|
|||
contentName = path;
|
||||
}
|
||||
|
||||
const nameBadChars = (channelName || name).match(/[^A-Za-z0-9-]/g);
|
||||
const nameBadChars = (channelName || name).match(lbryuri.REGEXP_INVALID_URI);
|
||||
if (nameBadChars) {
|
||||
throw new Error(
|
||||
__(
|
||||
|
@ -119,7 +121,7 @@ lbryuri.parse = function(uri, requireProto = false) {
|
|||
throw new Error(__("Only channel URIs may have a path."));
|
||||
}
|
||||
|
||||
const pathBadChars = path.match(/[^A-Za-z0-9-]/g);
|
||||
const pathBadChars = path.match(lbryuri.REGEXP_INVALID_URI);
|
||||
if (pathBadChars) {
|
||||
throw new Error(
|
||||
__(`Invalid character in path: %s`, pathBadChars.join(", "))
|
||||
|
|
Loading…
Add table
Reference in a new issue