mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 17:53:44 +08:00
Merge pull request #5282 from vinothkannans/local_onebox_slash
FIX: Topic links onebox differently if end in /
This commit is contained in:
commit
8f560f0bf4
|
@ -12,8 +12,7 @@ module Onebox
|
|||
url = other.to_s
|
||||
return false unless url[Discourse.base_url]
|
||||
|
||||
path = url.sub(Discourse.base_url, "")
|
||||
route = Rails.application.routes.recognize_path(path)
|
||||
route = Discourse.route_for(url)
|
||||
|
||||
!!(route[:controller] =~ /topics|uploads/)
|
||||
rescue ActionController::RoutingError
|
||||
|
@ -21,8 +20,9 @@ module Onebox
|
|||
end
|
||||
|
||||
def to_html
|
||||
path = @url.sub(Discourse.base_url, "")
|
||||
route = Rails.application.routes.recognize_path(path)
|
||||
uri = URI(@url)
|
||||
path = uri.path || ""
|
||||
route = Discourse.route_for(uri)
|
||||
|
||||
case route[:controller]
|
||||
when "uploads" then upload_html(path)
|
||||
|
|
|
@ -35,6 +35,11 @@ describe Onebox::Engine::DiscourseLocalOnebox do
|
|||
expect(html).to include(post2.excerpt)
|
||||
expect(html).to include(post2.topic.title)
|
||||
|
||||
url = "#{Discourse.base_url}#{post2.url}/?source_topic_id=#{post2.topic_id + 1}"
|
||||
html = Onebox.preview(url).to_s
|
||||
expect(html).to include(post2.excerpt)
|
||||
expect(html).to include(post2.topic.title)
|
||||
|
||||
html = Onebox.preview("#{Discourse.base_url}#{post2.url}").to_s
|
||||
expect(html).to include(post2.user.username)
|
||||
expect(html).to include(post2.excerpt)
|
||||
|
@ -65,6 +70,10 @@ describe Onebox::Engine::DiscourseLocalOnebox do
|
|||
html = Onebox.preview(topic.url).to_s
|
||||
expect(html).to include(topic.ordered_posts.first.user.username)
|
||||
expect(html).to include("<blockquote>")
|
||||
|
||||
html = Onebox.preview("#{topic.url}/?u=codinghorror").to_s
|
||||
expect(html).to include(topic.ordered_posts.first.user.username)
|
||||
expect(html).to include("<blockquote>")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user