From d200e68baba3c169eea6d52e3732b4d79c14890e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 10 Mar 2014 11:16:21 -0400 Subject: [PATCH] FIX: Link counter was broken for some https links --- app/models/topic_link_click.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/topic_link_click.rb b/app/models/topic_link_click.rb index 0719876f202..575b6a1e882 100644 --- a/app/models/topic_link_click.rb +++ b/app/models/topic_link_click.rb @@ -12,10 +12,9 @@ class TopicLinkClick < ActiveRecord::Base def self.create_from(args={}) # If the URL is absolute, allow HTTPS and HTTP versions of it - if args[:url] =~ /^http/ http_url = args[:url].sub(/^https/, 'http') - https_url = args[:url].sub(/^http/, 'https') + https_url = args[:url].sub(/^http\:/, 'https:') link = TopicLink.select([:id, :user_id]).where('url = ? OR url = ?', http_url, https_url) else link = TopicLink.select([:id, :user_id]).where(url: args[:url]) @@ -40,7 +39,6 @@ class TopicLinkClick < ActiveRecord::Base return args[:url] if (args[:user_id] && (link.user_id == args[:user_id])) - # Rate limit the click counts to once in 24 hours rate_key = "link-clicks:#{link.id}:#{args[:user_id] || args[:ip]}" if $redis.setnx(rate_key, "1")