Skip to content

Commit

Permalink
noDelimRegex hard coded string fix
Browse files Browse the repository at this point in the history
Had to move initialization of noDelimRegex variable inside the constructor to make use of options.attribute. Of course I also fixed all the references. All tests passed.
  • Loading branch information
Erik Kralj committed Apr 6, 2016
1 parent 9ba1592 commit d20aa1c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ function mkAttrRegex(startDelim, endDelim, attribute) {
return new RegExp(start + '\\s*(\'|"|"|')(.*?)\\1\\s*\\|\\s*' + attribute + '\\s*(' + end + '|\\|)', 'g');
}

var noDelimRegex = mkAttrRegex('', '');

function localeCompare(a, b) {
return a.localeCompare(b);
}
Expand Down Expand Up @@ -95,6 +93,7 @@ var Extractor = (function () {

this.strings = {};
this.attrRegex = mkAttrRegex(this.options.startDelim, this.options.endDelim, this.options.attribute);
this.noDelimRegex = mkAttrRegex('', '', this.options.attribute);
}

Extractor.isValidStrategy = function (strategy) {
Expand Down Expand Up @@ -354,10 +353,10 @@ var Extractor = (function () {
var attrValue = extracted[attr];
str = node.html(); // this shouldn't be necessary, but it is
self.addString(reference(n.startIndex), str || getAttr(attr) || '', attrValue.plural, attrValue.extractedComment, attrValue.context);
} else if (matches = noDelimRegex.exec(node.attr(attr))) {
} else if (matches = self.noDelimRegex.exec(node.attr(attr))) {
str = matches[2].replace(/\\\'/g, '\'');
self.addString(reference(n.startIndex), str);
noDelimRegex.lastIndex = 0;
self.noDelimRegex.lastIndex = 0;
}
}
});
Expand Down

0 comments on commit d20aa1c

Please sign in to comment.