diff options
author | Eric Wong <e@80x24.org> | 2016-05-02 04:22:40 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-05-02 17:57:07 +0000 |
commit | a0acd80571373595838617034540e1503f744737 (patch) | |
tree | ac4bd07b8541c243d7ebf27f94c448b7b7c479be /lib/PublicInbox/NewsGroup.pm | |
parent | 16d1d110117a2521fcc3304541c937385febd66b (diff) | |
download | public-inbox-a0acd80571373595838617034540e1503f744737.tar.gz |
For readers using NNTP, we should do our best to advertise the clonable HTTP/HTTPS URLs and the message permalink URL for ease-of-referencing messages, since we don't want the NNTP server and it's sequential article numbers to be relied on.
Diffstat (limited to 'lib/PublicInbox/NewsGroup.pm')
-rw-r--r-- | lib/PublicInbox/NewsGroup.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/PublicInbox/NewsGroup.pm b/lib/PublicInbox/NewsGroup.pm index adac919f..98a3595a 100644 --- a/lib/PublicInbox/NewsGroup.pm +++ b/lib/PublicInbox/NewsGroup.pm @@ -13,12 +13,21 @@ require PublicInbox::Search; require PublicInbox::Git; sub new { - my ($class, $name, $git_dir, $address) = @_; + my ($class, $name, $git_dir, $address, $url) = @_; + + # first email address is preferred $address = $address->[0] if ref($address); + if ($url) { + # assume protocol-relative URLs which start with '//' means + # the server supports both HTTP and HTTPS, favor HTTPS. + $url = "https:$url" if $url =~ m!\A//!; + $url .= '/' if $url !~ m!/\z!; + } my $self = bless { name => $name, git_dir => $git_dir, address => $address, + url => $url, }, $class; $self->{domain} = ($address =~ /\@(\S+)\z/) ? $1 : 'localhost'; $self; |