Port custom fnmatch to Library and conditionalise the only single use of
it