Cookie
view release on metacpan or search on metacpan
lib/Cookie/Domain.pm view on Meta::CPAN
sub encode
{
my $self = shift( @_ );
my $name = shift( @_ );
return( '' ) if( !length( $name ) );
# try-catch
local $@;
my $rv = eval
{
return( Net::IDN::Encode::domain_to_unicode( $name ) );
};
if( $@ )
{
return( $self->error( "An unexpected error occurred while encoding a domain name: $@" ) );
}
return( $rv );
}
sub file { return( shift->_set_get_object_without_init( 'file', 'Module::Generic::File', @_ ) ); }
lib/Cookie/Domain.pm view on Meta::CPAN
else
{
return( '' );
}
}
$suffix = $suffix->join( '.' );
$name = $labels->pop;
$sub = $labels->join( '.' ) if( $labels->length );
if( defined( $idn ) )
{
$suffix = Net::IDN::Encode::domain_to_unicode( $suffix );
$name = Net::IDN::Encode::domain_to_unicode( $name ) if( defined( $name ) );
$sub = Net::IDN::Encode::domain_to_unicode( $sub ) if( defined( $sub ) );
}
return(Cookie::Domain::Result->new({ name => $name, sub => $sub, suffix => $suffix }));
}
sub suffixes { return( shift->_set_get_hash_as_mix_object( 'suffixes', @_ ) ); }
# NOTE: Cookie::Domain::Result class
{
package
Cookie::Domain::Result;
lib/Cookie/Domain.pm view on Meta::CPAN
Or
use Cookie::Domain;
use Encode;
my $d = Cookie::Domain->new;
my $encoded = $d->encode( "xn--wmq0m700b.jp" );
say Encode::encode_utf8( $encoded );
If an error occurred, it sets an error object and returns L<perlfunc/undef>. The error can then be retrieved using L<Module::Generic/error> inherited by this module.
It uses L<Net::IDN::Encode/domain_to_unicode> to perform the actual encoding.
=head2 file
Sets the file path to the Public Suffix file. This file is a public domain file at the initiative of Mozilla Foundation and its latest version can be accessed here: L<https://publicsuffix.org/list/>
=head2 json_file
Sets the file path of the json cache data file. THe purpose of this file is to contain a json representation of the parsed data from the Public Suffix data file. This is to avoid re-parsing it each time and instead load the json file using the XS mod...
=head2 load
( run in 0.351 second using v1.01-cache-2.11-cpan-88abd93f124 )