Skip to content

Commit e2c089d

Browse files
committed
when searching for a package line, allow apostrophes in the module name
When searching for a package line to see if it is intentionally hidden, we are matching against the specific module that we are using. But the name that exists in the code could include apostrophes instead of double colons, while the recorded module name is normalized to use colons. Construct a regex to allow matching the module name but with apostrophe package separators.
1 parent f72eadb commit e2c089d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/MetaCPAN/Document/Module.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ my $bom
114114
sub hide_from_pause {
115115
my ( $self, $content, $file_name ) = @_;
116116
return 0 if defined($file_name) && $file_name =~ m{\.pm\.PL\z};
117-
my $pkg = $self->name;
117+
my $pkg = $self->name;
118+
my $pkg_match = join q[(?:::|')], map quotemeta, split m{::}, $pkg;
118119

119120
# This regexp is *almost* the same as $PKG_REGEXP in Module::Metadata.
120121
# [b] We need to allow/ignore a possible BOM since we read in binary mode.
@@ -128,7 +129,7 @@ sub hide_from_pause {
128129
[\h\{;]* # intro chars on a line [s]
129130
package # the word 'package'
130131
\h+ # whitespace [s]
131-
(\Q$pkg\E) # a package name [p]
132+
($pkg_match) # the package name [p]
132133
(\h+ v?[0-9._]+)? # optional version number (preceded by whitespace) [v]
133134
\h* # optional whitesapce [s]
134135
[;\{] # semicolon line terminator or block start

0 commit comments

Comments
 (0)