The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MarpaX::ESLIF::URI - URI as per RFC3986/RFC6874

VERSION

version 0.007

SYNOPSIS

  use feature 'say';
  use Data::Dumper;
  use MarpaX::ESLIF::URI;

  my  $http_url = "http://[2001:db8:a0b:12f0::1%25Eth0]:80/index.html";
  my  $http_uri = MarpaX::ESLIF::URI->new($http_url);
  say $http_uri->scheme;            # http
  say $http_uri->host;              # [2001:db8:a0b:12f0::1%Eth0]
  say $http_uri->hostname;          # 2001:db8:a0b:12f0::1%Eth0
  say $http_uri->path;              # /index.html
  say $http_uri->ip;                # 2001:db8:a0b:12f0::1%Eth0
  say $http_uri->ipv6;              # 2001:db8:a0b:12f0::1
  say $http_uri->zone;              # Eth0

  my  $file_url = "file:/c|/path/to/file";
  my  $file_uri = MarpaX::ESLIF::URI->new($file_url);
  say $file_uri->scheme;            # file
  say $file_uri->string;            # file:/c|/path/to/file
  say $file_uri->drive;             # c
  say $file_uri->path;              # /c|/path/to/file
  say Dumper($file_uri->segments);  # [ 'c|', 'path', 'to', 'file' ]

  my  $mail_url = "mailto:bogus\@email.com,bogus2\@email.com?"
                  . "subject=test%20subject&"
                  . "body=This%20is%20the%20body%20of%20this%20message.";
  my  $mail_uri = MarpaX::ESLIF::URI->new($mail_url);
  say $mail_uri->scheme;            # mailto
  say Dumper($mail_uri->to);        # bogus\@email.com, bogus2\@email.com
  say Dumper($mail_uri->headers);   # { 'subject' => 'test subject', 'body' => 'This is the body of this message.' }

SUBROUTINES/METHODS

$class->new($str, $scheme)

Returns a instance that is a MarpaX::ESLIF::URI::$scheme representation of $str, when $scheme defaults to _generic if there is no specific $scheme implementation, or if the later fails.

All methods of MarpaX::ESLIF::URI::_generic are available, sometimes extended or modified by specific scheme implementations.

NOTES

Percent-encoded characters are decoded to ASCII characters corresponding to every percent-encoded byte.

SEE ALSO

MarpaX::ESLIF::URI::_generic, MarpaX::ESLIF::URI::file, MarpaX::ESLIF::URI::ftp, MarpaX::ESLIF::URI::http, MarpaX::ESLIF::URI::https, MarpaX::ESLIF::URI::mailto, MarpaX::ESLIF::URI::tag, MarpaX::ESLIF::URI::tel.

AUTHOR

Jean-Damien Durand <jeandamiendurand@free.fr>

CONTRIBUTOR

Jean-Damien Durand <Jean-Damien.Durand@newaccess.ch>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Jean-Damien Durand.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.