URI::Nested(3pm)

πŸŽ€ Name πŸŽ€

okay so bestie, welcome to URI::Nested(3pm) β€” User Contributed Perl Documentation, and this is the manual for URI::Nested, aka Nested URIs. It’s giving β€œa URI inside a URI” main character energy, and we’re gonna get into it. πŸ’–

πŸ› οΈ Synopsis πŸ› οΈ

package URI::jdbc;
use parent 'URI::Nested';
sub prefix       { 'jdbc' }
sub nested_class { undef  }
sub subprotocol  { shift->nested_uri->scheme(@_) }

package main;
my $jdbc_uri = URI->new('jdbc:oracle:scott/tiger@//myhost:1521/myservicename');
my $nested_uri = $jdbc_uri->nested_uri;

🌸 Description 🌸

This class provides support for nested URIs, where the scheme is a prefix and the remainder of the URI is another URI. Examples include JDBC URIs (http://docs.oracle.com/cd/B14117_01/java.101/b10979/urls.htm#BEIJFHHB) and database URIs (https://github.com/theory/uri-db). Obsessed, honestly. ✨

πŸ’… Interface πŸ’…

The following differences exist compared to the URI class interface:

✨ Class Method ✨

  • prefix β€” Returns the prefix to be used, which corresponds to the URI’s scheme. Defaults to the last part of the class name.
  • nested_class β€” Returns the URI subclass to use for the nested URI. If defined, the nested URI will always be coerced into this class if it is not naturally an instance of this class or one of its subclasses.

πŸŽ€ Constructors πŸŽ€

  • new β€” yep, the constructor. Signatures are:
my $uri = URI::Nested->new($string);
my $uri = URI::Nested->new($string, $base);

Always returns a URI::Nested object. $base may be another URI object or string. Unlike in URI’s new(), schemes will always be applied to the URI and the nested URI if they don’t already have schemes. And if nested_class is defined, the nested URI will be coerced into that class. 🫢

πŸ” Accessors πŸ”

  • scheme β€” gets/sets the scheme part of the URI:
my $scheme = $uri->scheme;
$uri->scheme( $new_scheme );

When setting the scheme, it must always be the same as the value returned by prefix or an exception will be thrown β€” although the letter casing may vary. The returned value is always lowercase.

  • nested_uri β€” returns the nested URI:
my $nested_uri = $uri->nested_uri;

🧚 Instance Methods 🧚

  • abs β€” returns the URI::Nested object itself:
my $abs = $uri->abs( $base_uri );

Unlike URI’s abs(), $URI::ABS_ALLOW_RELATIVE_SCHEME is ignored. 😭

  • rel β€” returns the URI::Nested object itself:
my $rel = $uri->rel( $base_uri );

🫢 Support 🫢

This module is stored in an open GitHub repository (http://github.com/theory/uri-db/). Feel free to fork and contribute!

Please file bug reports via GitHub Issues (http://github.com/theory/uri-db/issues/) or by sending mail to bug-URI-db@rt.cpan.org.

πŸ‘‘ Author πŸ‘‘

David E. Wheeler β€” david@justatheory.com.

Copyright (c) 2013 David E. Wheeler. Some Rights Reserved.

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


okay bestie, that’s the whole manual πŸ’– β€” source/version perl v5.42.0, date 2015-04-24, manual URI::Nested(3pm). slay, periodt ✨

πŸ“¦ where this page comes from