libglob: only return dirs for globs ending in /

`foo.txt/` should return `foo.txt` if `foo.txt` is in fact a text file
and not a directory.