Assuming you're trying to capture the extension, there's another path function for this:

```javascript
path.extname(dir);
```