fix regular expression for lbry urls

This commit is contained in:
btzr-io 2019-06-02 16:33:47 -06:00
parent d6fae5c6ee
commit df44ca5bcf

View file

@ -16,9 +16,8 @@ const validateURI = (match, eat) => {
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 && !uri.path) {
return eat(text)(createURI(uri.claimName, text)); return eat(text)(createURI(uri.claimName, text));
} }
// Create uri link // Create uri link
@ -31,13 +30,13 @@ const validateURI = (match, eat) => {
// 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 = /^@+[a-zA-Z0-9-#:/]+/.exec(value);
return validateURI(match, eat); 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-zA-Z0-9-@#:/]+/.exec(value);
return validateURI(match, eat); return validateURI(match, eat);
} }