diff --git a/WebKit/scripts/helper/Core.js b/WebKit/scripts/helper/Core.js
index 8c6daa4..61b2c71 100644
--- a/WebKit/scripts/helper/Core.js
+++ b/WebKit/scripts/helper/Core.js
@@ -179,9 +179,13 @@ function(jQuery, Paths, URI, HostApp, Followings) {
template.in_reply.parentNode.className = "hidden";
var text = status.content.text.replace(/\n/g, "
");
+ var entities = [status.entity];
+ status.mentions.map(function (mention) {
+ entities.push(mention.entity)
+ });
template.message.innerHTML = this.replaceUsernamesWithLinks(
- this.replaceURLWithHTMLLinks(text, status.entities, template.message)
+ this.replaceURLWithHTMLLinks(text, entities, template.message)
);
this.findMentions(template.message, status.mentions);
@@ -380,17 +384,30 @@ function(jQuery, Paths, URI, HostApp, Followings) {
Core.prototype.replaceURLWithHTMLLinks = function(text, entities, message_node) {
- var exp = /(([^\^]https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_()|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
- return text.replace(exp, "$1");
+ var callback = function(url) {
+
+ var result;
+
+ if (entities && entities.some(function(x) { return x == url })) {
+ result = url;
+ } else {
+
+ var protocol = "";
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
+ protocol = "http://";
+ }
+ result = '' + url + '';
+ }
+
+ return result;
+ }
+
+ return URI.withinString(text, callback);
}
Core.prototype.replaceUsernamesWithLinks = function(text, mentions) {
-
- return text; // FIXME!
- var username = /(^|\s)(\^)(\w+)/ig;
var hash = /(^|\s)(#)(\w+)/ig;
- text = text.replace(username, "$1$2$3");
- return text.replace(hash, "$1$2$3");
+ return text.replace(hash, "$1$2$3");
}
Core.prototype.replyTo = function(entity, status_id, mentions) {