]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Inbox.pm
www_stream: linkify cloneurl entries if they're HTTP/HTTPS
[public-inbox.git] / lib / PublicInbox / Inbox.pm
index faab03ce4cb220d491dbf6d501956f49dcfa9289..34191fc79508f04ff9ce00cc3782333dd1c033bf 100644 (file)
@@ -5,18 +5,23 @@
 package PublicInbox::Inbox;
 use strict;
 use warnings;
-use Scalar::Util qw(weaken);
+use Scalar::Util qw(weaken isweak);
 use PublicInbox::Git;
 use PublicInbox::MID qw(mid2path);
 
 sub new {
        my ($class, $opts) = @_;
+       my $v = $opts->{address} ||= 'public-inbox@example.com';
+       my $p = $opts->{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v;
+       $opts->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost';
        bless $opts, $class;
 }
 
 sub weaken_all {
        my ($self) = @_;
-       weaken($self->{$_}) foreach qw(git mm search);
+       foreach my $f (qw(git mm search)) {
+               isweak($self->{$f}) or weaken($self->{$f});
+       }
 }
 
 sub git {