Convert to link as long as a valid link is received.

This commit is contained in:
Guo Xiang Tan 2016-01-29 13:31:11 +08:00
parent 190345ba20
commit e8c5127865
2 changed files with 3 additions and 3 deletions

View File

@ -14,8 +14,8 @@ Discourse.Dialect.inlineRegexp({
categoryHashtagLookup = this.dialect.options.categoryHashtagLookup,
result = categoryHashtagLookup && categoryHashtagLookup(slug);
if (result && result[0] === "category") {
return ['a', { class: attributeClass, href: result[1] }, '#', ["span", {}, slug]];
if (result) {
return ['a', { class: attributeClass, href: result }, '#', ["span", {}, slug]];
} else {
return ['span', { class: attributeClass }, hashtag];
}

View File

@ -50,7 +50,7 @@ module PrettyText
def category_hashtag_lookup(category_slug)
if category = Category.query_from_hashtag_slug(category_slug)
['category', category.url_with_id]
category.url_with_id
else
nil
end