Skip to content

Commit 595eb5f

Browse files
committed
Compare the name against self.normalized. Fixes #261 but also will cause 'lib' to match 'lib_foo'.
1 parent fea6e75 commit 595eb5f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

importlib_metadata/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,16 @@ def normalize(name):
497497
"""
498498
return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
499499

500-
def matches(self, name, base):
501-
n_low = name.lower()
500+
def matches(self, cand, base):
501+
low = cand.lower()
502+
pre, ext = os.path.splitext(low)
503+
name, sep, rest = pre.partition('-')
502504
return (
503-
n_low in self.exact_matches
504-
or n_low.replace('.', '_').startswith(self.prefix)
505-
and n_low.endswith(self.suffixes)
505+
low in self.exact_matches
506+
or name.replace('.', '_').startswith(self.normalized)
507+
and ext in self.suffixes
506508
# legacy case:
507-
or self.is_egg(base) and n_low == 'egg-info'
509+
or self.is_egg(base) and low == 'egg-info'
508510
)
509511

510512
def is_egg(self, base):

0 commit comments

Comments
 (0)