More accurately determine linkable sources
Use the "\A" metacharacter for the beginning of a string, instead of "^" for the beginning of any line within that string, and check for "://" as well. Fixes #1947.
This commit is contained in:
@@ -26,7 +26,7 @@ module PostsHelper
|
|||||||
text = "pixiv/#{$1}"
|
text = "pixiv/#{$1}"
|
||||||
source_link = link_to(text, post.normalized_source)
|
source_link = link_to(text, post.normalized_source)
|
||||||
source_search = "source:#{text}/"
|
source_search = "source:#{text}/"
|
||||||
elsif post.source =~ /^http/
|
elsif post.source =~ %r{\Ahttps?://}
|
||||||
text = truncate(post.normalized_source.sub(/^https?:\/\/(?:www\.)?/, ""))
|
text = truncate(post.normalized_source.sub(/^https?:\/\/(?:www\.)?/, ""))
|
||||||
source_link = link_to(truncate(text, :length => 20), post.normalized_source)
|
source_link = link_to(truncate(text, :length => 20), post.normalized_source)
|
||||||
source_search = "source:#{post.source.sub(/[^\/]*$/, "")}"
|
source_search = "source:#{post.source.sub(/[^\/]*$/, "")}"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<entry>
|
<entry>
|
||||||
<title><%= post.presenter.humanized_essential_tag_string %></title>
|
<title><%= post.presenter.humanized_essential_tag_string %></title>
|
||||||
<link href="http://<%= Danbooru.config.hostname %>/posts/<%= post.id %>" rel="alternate"/>
|
<link href="http://<%= Danbooru.config.hostname %>/posts/<%= post.id %>" rel="alternate"/>
|
||||||
<% if post.source =~ /^http/ %>
|
<% if post.source =~ %r{\Ahttps?://} %>
|
||||||
<link href="<%= post.source %>" rel="related"/>
|
<link href="<%= post.source %>" rel="related"/>
|
||||||
<% end %>
|
<% end %>
|
||||||
<id>http://<%= Danbooru.config.hostname %>/posts/<%= post.id %></id>
|
<id>http://<%= Danbooru.config.hostname %>/posts/<%= post.id %></id>
|
||||||
|
|||||||
Reference in New Issue
Block a user