<commit_before>require 'nokogiri'

module ExtractUrls
  # Extract image URLs from HTML.
  def extract_image_urls(url, body)
    urls = []
    Nokogiri::HTML(body).xpath('//a[@href]').each do |link|
      urls += [URI.join(url, link[:href]).to_s] if link[:href] =~ /\.(png|jpg|jpeg)\z/i
    end
    return urls
  end

  module_function :extract_image_urls
end
<commit_msg>Enabsolute the source url (breaks when the url doesn't end with /).<commit_after>require 'nokogiri'

module ExtractUrls
  # Extract image URLs from HTML.
  def extract_image_urls(url, body)
    urls = []
    Nokogiri::HTML(body).xpath('//a[@href]').each do |link|
      urls += [URI.join("#{url}/", link[:href]).to_s] if link[:href] =~ /\.(png|jpg|jpeg)\z/i
    end
    return urls
  end

  module_function :extract_image_urls
end

{'fraction_non_alphanumeric': 0.15586034912718205, 'fraction_numerical': 0.0, 'mean_word_length': 3.695906432748538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6394905', 'n_tokens_mistral': 306, 'n_tokens_neox': 296, 'n_words': 69}