bkotu6717/brilliant_web_scraper

View on GitHub
lib/parsers/pinterest_profile.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

# Grep pinterest profile
module PinterestProfile
  def grep_pinterest_profile(response)
    return if response.nil? || response.empty?

    pinterest_regex = %r{(?im)(https?:\/\/[\w\.]*pinterest\.com\/(?!"|'|\?|#|cookies(?:"|'')|(?:pin|v3|js|feed)\/)[^"'<>?&\s\/]+)}
    response.scan(pinterest_regex).flatten.compact.uniq
  end
end