From 24ff1767442b2cf1f8619e1f3c69c5e8eeb058ed Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 27 May 2019 20:56:44 -0600 Subject: [PATCH] Update Autolinker --- app/Util/Lexer/Autolink.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Util/Lexer/Autolink.php b/app/Util/Lexer/Autolink.php index 285ff65da..4ec8c2ef7 100755 --- a/app/Util/Lexer/Autolink.php +++ b/app/Util/Lexer/Autolink.php @@ -418,7 +418,7 @@ class Autolink extends Regex if(Str::startsWith($entity['screen_name'], '@')) { $text .= StringUtils::substr($tweet, $beginIndex, $entity['indices'][0] - $beginIndex); } else { - $text .= StringUtils::substr($tweet, $beginIndex, $entity['indices'][0] - $beginIndex + 1); + $text .= StringUtils::substr($tweet, $beginIndex, $entity['indices'][0] - $beginIndex); } } else { $text .= StringUtils::substr($tweet, $beginIndex, $entity['indices'][0] - $beginIndex); @@ -708,16 +708,17 @@ class Autolink extends Regex { $attributes = []; + $screen_name = $entity['screen_name']; if (!empty($entity['list_slug'])) { // Replace the list and username - $linkText = $entity['screen_name']; + $linkText = Str::startsWith($screen_name, '@') ? $screen_name : '@'.$screen_name; $class = $this->class_list; - $url = $this->url_base_list.$linkText; + $url = $this->url_base_list.$screen_name; } else { // Replace the username - $linkText = $entity['screen_name']; + $linkText = Str::startsWith($screen_name, '@') ? $screen_name : '@'.$screen_name; $class = $this->class_user; - $url = $this->url_base_user.$linkText; + $url = $this->url_base_user.$screen_name;; } if (!empty($class)) { $attributes['class'] = $class;