link parser from string

This commit is contained in:
Harry Bomrah 2015-10-02 18:33:29 +08:00
parent bdeb70c5fb
commit 9636c57aa8
1 changed files with 10 additions and 0 deletions

View File

@ -3,6 +3,11 @@ module TicketsHelper
if !site.nil?
html = html.gsub("href=\"/uploads/","href=\"http://#{site.site_domain}/uploads/")
html = html.gsub("src=\"/uploads/","src=\"http://#{site.site_domain}/uploads/")
temp_html = ActionView::Base.full_sanitizer.sanitize(html)
urls = URI.extract(temp_html,["http","https"])
urls.each do |url|
html = html.sub(url, "<a href='#{url}' target='_blank'>#{url}</a>")
end
end
return html
end
@ -10,6 +15,11 @@ module TicketsHelper
def smart_store_link_parser(html)
html = html.gsub("href=\"/uploads/","href=\"http://#{request.host_with_port}/uploads/")
html = html.gsub("src=\"/uploads/","src=\"http://#{request.host_with_port}/uploads/")
temp_html = ActionView::Base.full_sanitizer.sanitize(html)
urls = URI.extract(temp_html,["http","https"])
urls.each do |url|
html = html.sub(url, "<a href='#{url}' target='_blank'>#{url}</a>")
end
return html
end