lib/cms_scanner/target/scope.rb
def scope_url_pattern
      return @scope_url_pattern if @scope_url_pattern

      domains = [uri.host + uri.path]

      domains += if scope.domains.empty?
                   [*scope.invalid_domains[1..-1]]
                 else
                   [*scope.domains[1..-1]].map(&:to_s) + scope.invalid_domains
                 end

      domains.map! { |d| Regexp.escape(d.gsub(%r{/$}, '')).gsub('\*', '.*').gsub('/', '\\\\\?/') }

      domains[0].gsub!(Regexp.escape(uri.host), Regexp.escape(uri.host) + '(?::\\d+)?') if uri.port

      @scope_url_pattern = %r{https?:\\?/\\?/(?:#{domains.join('|')})\\?/?}i
    end
def scope_url_pattern
      return @scope_url_pattern if @scope_url_pattern

      domains = [uri.host + uri.path]

      domains += if scope.domains.empty?
                   [*scope.invalid_domains[1..-1]]
                 else
                   [*scope.domains[1..-1]].map(&:to_s) + scope.invalid_domains
                 end

      domains.map! { |d| Regexp.escape(d.gsub(%r{/$}, '')).gsub('\*', '.*').gsub('/', '\\\\\?/') }

      domains[0].gsub!(Regexp.escape(uri.host), Regexp.escape(uri.host) + '(?::\\d+)?') if uri.port

      @scope_url_pattern = %r{https?:\\?/\\?/(?:#{domains.join('|')})\\?/?}i
    end
Similar to Target#url_pattern but considering the in scope domains as well

 @return [ Regexp ] The pattern related to the target url and in scope domains,
                    it also matches escaped /, such as in JSON JS data: http:\/\/t.com\/
 rubocop:disable Metrics/AbcSize