2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FIX: httpshttps ultra secure URLs

This commit is contained in:
Régis Hanol 2016-06-30 16:55:01 +02:00
parent 7a1e99dacb
commit 5169bcdb6e
9 changed files with 54 additions and 75 deletions

View file

@ -37,18 +37,11 @@ module PrettyText
UrlHelper.schemaless UrlHelper.absolute avatar_template
end
def mention_lookup(username)
return false unless username
if Group.exec_sql('SELECT 1 FROM groups WHERE name = ?', username).values.length == 1
"group"
else
username = username.downcase
if User.exec_sql('SELECT 1 FROM users WHERE username_lower = ?', username).values.length == 1
"user"
else
nil
end
end
def mention_lookup(name)
return false if name.blank?
return "group" if Group.where(name: name).exists?
return "user" if User.where(username_lower: name.downcase).exists?
nil
end
def category_hashtag_lookup(category_slug)
@ -306,12 +299,7 @@ JS
def self.add_s3_cdn(doc)
doc.css("img").each do |img|
next unless img["src"]
if img["src"].include? Discourse.store.absolute_base_url
src = img["src"].sub(Discourse.store.absolute_base_url, SiteSetting.s3_cdn_url)
# absolute is // style so we may have added an extra https:// here
src = src.sub(/https?:h/, "h")
img["src"] = src
end
img["src"] = Discourse.store.cdn_url(img["src"])
end
end