]> Sergey Matveev's repositories - public-inbox.git/commitdiff
URIimap: overload "" to ->as_string
authorEric Wong <e@80x24.org>
Fri, 19 Feb 2021 12:09:55 +0000 (05:09 -0700)
committerEric Wong <e@80x24.org>
Fri, 19 Feb 2021 19:25:25 +0000 (19:25 +0000)
This interpolation is used by the upstream URI package
and we rely on it elsewhere for HTTP(S) URIs, so save
ourselves some surprises down the line.

lib/PublicInbox/URIimap.pm
t/uri_imap.t
xt/net_writer-imap.t

index ab0908b7197941ecbacc47fdd676b9b20af1b1d3..db84ee5ef61ed4b53cfe4c0239295f32ca8a7f28 100644 (file)
@@ -13,6 +13,7 @@ package PublicInbox::URIimap;
 use strict;
 use URI::Split qw(uri_split uri_join); # part of URI
 use URI::Escape qw(uri_unescape);
+use overload '""' => \&as_string;
 
 my %default_ports = (imap => 143, imaps => 993);
 
index 6c4207c3aefaf6e2e20cbc4022554ce110f95b94..f7c7866535503da5ce7cb5930ec3f8df8f9aabe6 100644 (file)
@@ -19,6 +19,7 @@ is($uri->auth, undef);
 is($uri->user, undef);
 
 $uri = PublicInbox::URIimap->new('imaps://foo@0/');
+is("$uri", $uri->as_string, '"" overload works');
 is($uri->host, '0', 'numeric host');
 is($uri->user, 'foo', 'user extracted');
 
index ea812f16db9d8019acd5bd17d8c74a626b976b8d..dfd765be7a70699883e017e8102da99b9dd77856 100644 (file)
@@ -29,7 +29,7 @@ $nwr->{pi_cfg} = bless {}, 'PublicInbox::Config';
 my $mics = $nwr->imap_common_init;
 my $mic = (values %$mics)[0];
 my $cleanup = PublicInbox::OnDestroy->new(sub {
-       $mic->delete($folder) or fail "delete $folder <$$folder_uri>: $@";
+       $mic->delete($folder) or fail "delete $folder <$folder_uri>: $@";
 });
 my $imap_append = $nwr->can('imap_append');
 my $smsg = bless { kw => [ 'seen' ] }, 'PublicInbox::Smsg';