Sha256: ba54dfaf510f91c8ab248230187c6d01d379d88007e47fd977d050e5f91154bf

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# Propagates an initial list of best-guess government domains

require 'public_suffix'
require 'yaml'
require_relative '../lib/gman'

# https://gist.github.com/benbalter/6147066
REGEX = /(\.g[ou]{1,2}(v|b|vt)|\.mil|\.gc|\.fed)(\.[a-z]{2})?$/i.freeze

domains = []
PublicSuffix::List.default.each do |rule|
  domain = nil

  if rule.parts.length == 1
    domain = rule.parts.first if ".#{rule.value}" =~ REGEX
  elsif ".#{rule.value}" =~ REGEX
    domain = rule.parts.pop(2).join('.')
  end

  domains.push domain unless domain.nil? || domains.include?(domain)
end

# Note: We want to skip resolution here, because a domain like `gov.sv` may be
# a valid TLD, not have any top-level sites, and we'd still want it listed
Gman::Importer.new('non-us gov' => domains).import(skip_resolve: true)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gman-7.0.3 script/vendor-public-suffix