Handle links with no href in VerifyLinkService (#20741)
Before this change, the following error would cause VerifyAccountLinksWorker to fail: NoMethodError: undefined method `downcase' for nil:NilClass [PROJECT_ROOT]/app/services/verify_link_service.rb:31 :in `block in link_back_present?`
This commit is contained in:
parent
cbb0153bd0
commit
daf6f3453e
2 changed files with 22 additions and 2 deletions
|
@ -28,7 +28,7 @@ class VerifyLinkService < BaseService
|
|||
|
||||
links = Nokogiri::HTML(@body).xpath('//a[contains(concat(" ", normalize-space(@rel), " "), " me ")]|//link[contains(concat(" ", normalize-space(@rel), " "), " me ")]')
|
||||
|
||||
if links.any? { |link| link['href'].downcase == @link_back.downcase }
|
||||
if links.any? { |link| link['href']&.downcase == @link_back.downcase }
|
||||
true
|
||||
elsif links.empty?
|
||||
false
|
||||
|
@ -38,6 +38,8 @@ class VerifyLinkService < BaseService
|
|||
end
|
||||
|
||||
def link_redirects_back?(test_url)
|
||||
return false if test_url.blank?
|
||||
|
||||
redirect_to_url = Request.new(:head, test_url, follow: false).perform do |res|
|
||||
res.headers['Location']
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue