millermedeiros/esformatter-quotes — pull request #6 by twolfson (2014-11-04 02:52:42+00:00)
Title: Added replacement for leading quotes. Fixes #5

As mentioned in #5, there was a problem with replacing strings like `"'"` (double single double). I traced down the issue to:

https://github.com/millermedeiros/esformatter-quotes/blob/v1.0.0/index.js#L48-L49

```js
var quoteEscape = new RegExp('([^\\\\])' + quote, 'g');
content = content.replace(quoteEscape, '$1\\' + quote);
```

This `RegExp` searches for a non-slash character followed by a quote. Unfortunately, at the start of the string there are no preceding characters so this first one gets skipped. To resolve this, I moved the group to match against `^` (start of string) or non-slash character:

```js
var quoteEscape = new RegExp('([^|^\\\\])' + quote, 'g');
```

In this PR:

- Added test cases against leading string character
- Patched `index.js` with updated `RegExp`