`invalidChars` should only be set once in this block of code:

```
        var invalidChars;
        
        if (brackets.platform === "mac") {
            invalidChars = "?*|:";
        } else if (brackets.platform === "linux") {
            invalidChars = "?*|/";
        } else {
            invalidChars = "/?*:<>\\|\"";  // invalid characters on Windows
        }
```

It might also be worth making `invalidChars` to be module scope so it's only set once per session because it will be the same every time this function is called.