about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-19 05:09:55 -0700
committerEric Wong <e@80x24.org>2021-02-19 19:25:25 +0000
commitae31a9e82c34727ba15e98f6ec63481cb8429606 (patch)
tree3bcf822f17bf572431b572de9fd326f8b6d7db88
parentbf367c9ac999e2e64a53ead083f68b171d9f6d35 (diff)
downloadpublic-inbox-ae31a9e82c34727ba15e98f6ec63481cb8429606.tar.gz
URIimap: overload "" to ->as_string
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.
-rw-r--r--lib/PublicInbox/URIimap.pm1
-rw-r--r--t/uri_imap.t1
-rw-r--r--xt/net_writer-imap.t2
3 files changed, 3 insertions, 1 deletions
diff --git a/lib/PublicInbox/URIimap.pm b/lib/PublicInbox/URIimap.pm
index ab0908b7..db84ee5e 100644
--- a/lib/PublicInbox/URIimap.pm
+++ b/lib/PublicInbox/URIimap.pm
@@ -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);
 
diff --git a/t/uri_imap.t b/t/uri_imap.t
index 6c4207c3..f7c78665 100644
--- a/t/uri_imap.t
+++ b/t/uri_imap.t
@@ -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');
 
diff --git a/xt/net_writer-imap.t b/xt/net_writer-imap.t
index ea812f16..dfd765be 100644
--- a/xt/net_writer-imap.t
+++ b/xt/net_writer-imap.t
@@ -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';