about summary refs log tree commit homepage
path: root/lib/PublicInbox/NetReader.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-06-11 09:42:40 +0000
committerEric Wong <e@80x24.org>2021-06-12 00:05:59 +0000
commit26c426cf6fd9a3f44f11fa30e4824aeac574a6a0 (patch)
treee1b383bae5485a7302b2145e71167e902c7e55fe /lib/PublicInbox/NetReader.pm
parentbe365fb4bd3eda10294d4a916321c28b90dd723d (diff)
downloadpublic-inbox-26c426cf6fd9a3f44f11fa30e4824aeac574a6a0.tar.gz
While other tools can provide the same functionality, having
integration with git-credential is convenient, here.  Caching
and completion will be implemented separately.
Diffstat (limited to 'lib/PublicInbox/NetReader.pm')
-rw-r--r--lib/PublicInbox/NetReader.pm15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index 2795a9d4..bcc6cbf0 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -236,18 +236,19 @@ W: see https://rt.cpan.org/Ticket/Display.html?id=129967 for updates
 }
 
 sub imap_uri {
-        my ($url) = @_;
+        my ($url, $ls_ok) = @_;
         require PublicInbox::URIimap;
         my $uri = PublicInbox::URIimap->new($url);
-        $uri ? $uri->canonical : undef;
+        $uri && ($ls_ok || $uri->mailbox) ? $uri->canonical : undef;
 }
 
 my %IS_NNTP = (news => 1, snews => 1, nntp => 1, nntps => 1);
 sub nntp_uri {
-        my ($url) = @_;
+        my ($url, $ls_ok) = @_;
         require PublicInbox::URInntps;
         my $uri = PublicInbox::URInntps->new($url);
-        $uri && $IS_NNTP{$uri->scheme} && $uri->group ? $uri->canonical : undef;
+        $uri && $IS_NNTP{$uri->scheme} && ($ls_ok || $uri->group) ?
+                $uri->canonical : undef;
 }
 
 sub cfg_intvl ($$$) {
@@ -367,11 +368,11 @@ sub nntp_common_init ($;$) {
 }
 
 sub add_url {
-        my ($self, $arg) = @_;
+        my ($self, $arg, $ls_ok) = @_;
         my $uri;
-        if ($uri = imap_uri($arg)) {
+        if ($uri = imap_uri($arg, $ls_ok)) {
                 push @{$self->{imap_order}}, $uri;
-        } elsif ($uri = nntp_uri($arg)) {
+        } elsif ($uri = nntp_uri($arg, $ls_ok)) {
                 push @{$self->{nntp_order}}, $uri;
         } else {
                 push @{$self->{unsupported_url}}, $arg;