We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I would like to query the default list to determine if a domain wildcard rule is actually a public suffix rule.
list['*.wired.com'] # => nil list['*.com'] # => #<PublicSuffix::Rule::Normal:0x007f9870738bc8 @name="com", @value="com", @type=:normal, @labels=["com"]>
The text was updated successfully, but these errors were encountered:
This is tricky, as the list is not stored in a simple Hash (to increase the lookup performance). However, the request makes sense.
I'll see what I can do.
Sorry, something went wrong.
It is not quite clear to me what the API you are looking for, but this is close. Maybe you could tell me more.
#!/usr/bin/env ruby require 'public_suffix' module PublicSuffix class List def [](x) myhash = Hash.new x.split(DOT).reverse[0..0].each do |p| if @indexes.include?(p) @indexes[p].each do |r| if @rules[r].wildcard? myhash['*.' + @rules[r].value] = @rules[r] else myhash['' + @rules[r].value] = @rules[r] end end end end myhash[x] || nil end end end list = PublicSuffix::List.default %w(as com wired.com *.api.githubcloud.com compute.amazonaws.com).each do |name| puts "#{name} #{list[name].inspect}" end
Closing, as you can currently take advantage of the Rule#each returning an Enumerator.
PublicSuffix::List.default.each.find { |r| r.rule == "*.wired.com" } # => nil PublicSuffix::List.default.each.find { |r| r.rule == "com" } # => #<PublicSuffix::Rule::Normal:0x00007fe049034040 @value="com", @length=1, @private=false>
weppos
No branches or pull requests
I would like to query the default list to determine if a domain wildcard rule is actually a public suffix rule.
The text was updated successfully, but these errors were encountered: