diff --git a/lib/MetaCPAN/Document/File.pm b/lib/MetaCPAN/Document/File.pm index ccf94edf9..058068b85 100644 --- a/lib/MetaCPAN/Document/File.pm +++ b/lib/MetaCPAN/Document/File.pm @@ -704,6 +704,12 @@ does not include any modules, the L property is true. sub set_indexed { my ( $self, $meta ) = @_; + foreach my $mod ( @{ $self->module } ) { + if ( $mod->name =~ /^[_*]/ ) { + $mod->indexed(0); + } + } + foreach my $mod ( @{ $self->module } ) { $mod->indexed( $meta->should_index_package( $mod->name ) diff --git a/t/document/file.t b/t/document/file.t index 55023e538..0ee761e90 100644 --- a/t/document/file.t +++ b/t/document/file.t @@ -171,6 +171,14 @@ END }; }; +subtest 'Packages starting with underscore are not indexed' => sub { + my $file = MetaCPAN::Document::File->new( %stub, + module => { name => '_Package::Foo' } ); + + $file->set_indexed( CPAN::Meta->new( { name => 'null', version => 0 } ) ); + is( $file->module->[0]->indexed, 0, 'Package is not indexed' ); +}; + subtest 'module below .../t/' => sub { my $file = MetaCPAN::Document::File->new( %stub,