Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

mruby-publicsuffix Build Status

Public Suffix List for mruby. The purpose of this project is mruby port of publicsuffix-ruby.

NOTE

mruby-publicsuffix aims at porting from publicsuffix-ruby, but there's some differences, so it cannot provide totally the same functionality.

Requirements

  • mruby >= 1.3.0

Installation

You can add conf.gem line to build_config.rb:

MRuby::Build.new do |conf|

    # ... (snip) ...

    conf.gem mgem: 'mruby-publicsuffix'
end

PublicSuffix class methods

PublicSuffix.domain

PublicSuffix.domain extracts the domain out from a given name and returns it as String class.

PublicSuffix.domain('google.com')
# => "google.com"

If given a domain with subdomains, returning the domain.

PublicSuffix.domain('www.google.com')
# => "google.com"
PublicSuffix.domain('www.google.co.uk')
# => "google.co.uk"

This library automatically recognizes FQDN (Fully Qualified Domain Names). A FQDN is a domain name that end with a trailing dot.

PublicSuffix.domain("www.google.com.")
# => "google.com"

PublicSuffix.parse

PublicSuffix.parse parses a domain and returns an object of PublicSuffix::Domain class. This method support a domain with subdomains.

domain = PublicSuffix.parse('www.google.com')
# => #<PublicSuffix::Domain:0x7fa3bf84c9b0>

PublicSuffix.valid?

Checks whether a given domain is assigned and allowed, without actually parsing it. This method doesn't care whether domain is a domain or subdomain. The validation is performed using the default PublicSuffix::List.

Simple validation example:

PublicSuffix.valid?("google.com")
# => true

# Explicitly forbidden, it is listed as a private domain
> PublicSuffix.valid?("blogspot.com")
# => false

# Unknown/not-listed TLD domains are valid by default
> PublicSuffix.valid?("example.tldnotlisted")
# => true

Strict validation (without applying the default * rule):

> PublicSuffix.valid?("example.tldnotlisted", PublicSuffix::List.default, nil)
# => false

License

under the MIT License:

  • see LICENSE file

About

Public Suffix List for mruby. The purpose of this project is mruby port of publicsuffix-ruby.

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Languages