Skip to content
Snippets Groups Projects
Unverified Commit 96f51e59 authored by Emily Strickland's avatar Emily Strickland Committed by GitHub
Browse files

Guard against error extracting `body` from URL (#20428)

If `Nokogiri::HTML(value).at_xpath('//body')` fails to find the `body` element, it will return `nil`. We can guard against that with an early return. Avoids calling `children` on `Nilclass` in those cases.
parent 31005aad
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,7 @@ class Account::Field < ActiveModelSerializers::Model
def extract_url_from_html
doc = Nokogiri::HTML(value).at_xpath('//body')
return if doc.nil?
return if doc.children.size > 1
element = doc.children.first
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment