diff options
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/emoji.rb | 4 | ||||
-rw-r--r-- | app/lib/exceptions.rb | 10 | ||||
-rw-r--r-- | app/lib/language_detector.rb | 4 |
3 files changed, 8 insertions, 10 deletions
diff --git a/app/lib/emoji.rb b/app/lib/emoji.rb index e444b6893..45b7f53de 100644 --- a/app/lib/emoji.rb +++ b/app/lib/emoji.rb @@ -6,7 +6,7 @@ class Emoji include Singleton def initialize - data = Oj.load(File.open(File.join(Rails.root, 'lib', 'assets', 'emoji.json'))) + data = Oj.load(File.open(Rails.root.join('lib', 'assets', 'emoji.json'))) @map = {} @@ -32,7 +32,7 @@ class Emoji def codepoint_to_unicode(codepoint) if codepoint.include?('-') - codepoint.split('-').map(&:hex).pack('U') + codepoint.split('-').map(&:hex).pack('U*') else [codepoint.hex].pack('U') end diff --git a/app/lib/exceptions.rb b/app/lib/exceptions.rb index 34d84a34f..b2489711d 100644 --- a/app/lib/exceptions.rb +++ b/app/lib/exceptions.rb @@ -8,11 +8,11 @@ module Mastodon class UnexpectedResponseError < Error def initialize(response = nil) - @response = response - end - - def to_s - "#{@response.uri} returned code #{@response.code}" + if response.respond_to? :uri + super("#{response.uri} returned code #{response.code}") + else + super + end end end end diff --git a/app/lib/language_detector.rb b/app/lib/language_detector.rb index 6d6ae2fb3..cc7509fdc 100644 --- a/app/lib/language_detector.rb +++ b/app/lib/language_detector.rb @@ -33,9 +33,7 @@ class LanguageDetector def simplified_text text.dup.tap do |new_text| - URI.extract(new_text).each do |url| - new_text.gsub!(url, '') - end + new_text.gsub!(FetchLinkCardService::URL_PATTERN, '') new_text.gsub!(Account::MENTION_RE, '') new_text.gsub!(Tag::HASHTAG_RE, '') new_text.gsub!(/\s+/, ' ') |