Are you sure this will match correctly? Shouldn't "*.foo.bar" be translated into a regex like /foo\.bar$/? Note two things: 1) escape regex meta chars (e.g. "." becomes "\.") and 2) anchor at end.