fix validatenURI function
This commit is contained in:
parent
b7c652b554
commit
d6fae5c6ee
1 changed files with 6 additions and 5 deletions
|
@ -11,11 +11,12 @@ const createURI = (text, uri) => ({
|
||||||
children: [{ type: 'text', value: text }],
|
children: [{ type: 'text', value: text }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const validateURI = (match) => {
|
const validateURI = (match, eat) => {
|
||||||
if (match) {
|
if (match) {
|
||||||
try {
|
try {
|
||||||
const text = match[0];
|
const text = match[0];
|
||||||
const uri = parseURI(text);
|
const uri = parseURI(text);
|
||||||
|
console.info(text);
|
||||||
// Create channel link
|
// Create channel link
|
||||||
if (uri.isChannel) {
|
if (uri.isChannel) {
|
||||||
return eat(text)(createURI(uri.claimName, text));
|
return eat(text)(createURI(uri.claimName, text));
|
||||||
|
@ -26,18 +27,18 @@ const validateURI = (match) => {
|
||||||
// Silent errors: console.error(err)
|
// Silent errors: console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Generate a markdown link from channel name
|
// Generate a markdown link from channel name
|
||||||
function tokenizeMention(eat, value, silent) {
|
function tokenizeMention(eat, value, silent) {
|
||||||
const match = /^@(\w+)/.exec(value);
|
const match = /^@(\w+)/.exec(value);
|
||||||
return validateURI(match);
|
return validateURI(match, eat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a markdown link from lbry url
|
// Generate a markdown link from lbry url
|
||||||
function tokenizeURI(eat, value, silent) {
|
function tokenizeURI(eat, value, silent) {
|
||||||
const match = /^(lbry:\/\/)+([A-z0-9-_#@])+/.exec(value);
|
const match = /^(lbry:\/\/)+([A-z0-9-_#@:])+/.exec(value);
|
||||||
return validateURI(match);
|
return validateURI(match, eat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure tokenizer for lbry urls
|
// Configure tokenizer for lbry urls
|
||||||
|
|
Loading…
Add table
Reference in a new issue