Convert Pathname to String in order to apply regular expression