]> Sergey Matveev's repositories - public-inbox.git/blob - t/hval.t
a3712666d617511a5fc8fcc2b376244fc38b1014
[public-inbox.git] / t / hval.t
1 # Copyright (C) 2017 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 use strict;
4 use warnings;
5 use Test::More;
6 use_ok 'PublicInbox::Hval';
7
8 my $ibx = {
9         -no_obfuscate_re => qr/(?:example\.com)\z/i,
10         -no_obfuscate => {
11                 'meta@public-inbox.org' => 1,
12         }
13 };
14
15 my $html = <<'EOF';
16 hello@example.comm
17 hello@example.com
18 meta@public-inbox.org
19 test@public-inbox.org
20 test@a.b.c.org
21 EOF
22
23 PublicInbox::Hval::obfuscate_addrs($ibx, $html);
24
25 my $exp = <<'EOF';
26 hello@example&#8226;comm
27 hello@example.com
28 meta@public-inbox.org
29 test@public-inbox&#8226;org
30 test@a&#8226;b.c.org
31 EOF
32
33 is($html, $exp, 'only obfuscated relevant addresses');
34
35 done_testing();