Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case sensitivity and regex settings broken #13

Open
pcworld opened this issue Jun 26, 2020 · 0 comments
Open

Case sensitivity and regex settings broken #13

pcworld opened this issue Jun 26, 2020 · 0 comments

Comments

@pcworld
Copy link

pcworld commented Jun 26, 2020

tree.view.getCellValue returns a string, thus it needs to be parsed (e.g. using === "true"), for both of these values:

removal.caseSensitive = tree.view.getCellValue(i, tree.columns.getColumnAt(SubjectCleanerOptions.COLINDEX_CASE_SENSITIVE));
removal.regexp = tree.view.getCellValue(i, tree.columns.getColumnAt(SubjectCleanerOptions.COLINDEX_REGULAR_EXPRESSION));

Due to that bug, these if conditions are currently broken as the strings "true" and "false" are truthy in JS:

var flags = "g";
if(!removalList[i].caseSensitive){
flags += "i";
}
if(removalList[i].regexp){
dstSubject = dstSubject.replace(new RegExp(removalList[i].removalString, flags), '');
}else{
dstSubject = dstSubject.replace(removalList[i].removalString, '', flags);
}

Further, case sensitivity setting won't work for non-regexes once the regex setting is fixed, because replace() doesn't have a flags parameter (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace):

dstSubject = dstSubject.replace(removalList[i].removalString, '', flags);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant