Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixes #60

  • Loading branch information...
commit 240606d0bbafae491d9d474c2b2037d580ce0584 1 parent 3e56943
Josh Perez authored August 06, 2012
14  fixmyjs.js
@@ -153,15 +153,13 @@
153 153
 // `person['name']` -> `person.name`
154 154
       dotNotation: function (str, o) {
155 155
         var dot = o.a;
156  
-        var rx = new RegExp('\\[[\'"]' + dot + '[\'"]\\]');
157  
-        var sqbNotation;
  156
+        var rx = new RegExp('\\[[\'"]' +
  157
+          dot + '[\'"]\\]?(?!.*\\[[\'"]' +
  158
+          dot + '[\'"]\\]?)');
158 159
 
159  
-        if (rx.test(str)) {
160  
-          sqbNotation = rx.exec(str);
161  
-          str = str.replace(sqbNotation[0], "." + dot);
162  
-        }
163  
-
164  
-        return str;
  160
+        return str.replace(rx, function () {
  161
+          return '.' + dot;
  162
+        });
165 163
       },
166 164
 
167 165
 // Immediate functions are executed within the parenthesis.
2  test/fixtures/broken/dotnotation.js
@@ -18,3 +18,5 @@ lol["cats"];
18 18
 hello["return"];
19 19
 
20 20
 foo["for"]; foo["that"]; foo['this'];
  21
+
  22
+window['foo'] = window['foo'] || function () {};
2  test/fixtures/ok/dotnotation.js
@@ -18,3 +18,5 @@ lol.cats;
18 18
 hello["return"];
19 19
 
20 20
 foo["for"]; foo.that; foo['this'];
  21
+
  22
+window.foo = window.foo || function () {};

0 notes on commit 240606d

Please sign in to comment.
Something went wrong with that request. Please try again.