Add support for labels containing single/double quote

This commit is contained in:
Clement Ho 2016-11-14 22:14:29 -06:00
parent 8be495318e
commit 976893ec2f
2 changed files with 17 additions and 9 deletions

View File

@ -62,10 +62,20 @@
const keyMatch = this.validTokenKeys.filter(v => v.key === tokenKey)[0];
const symbolMatch = this.validTokenKeys.filter(v => v.symbol === tokenSymbol)[0];
if (tokenValue.indexOf('"') !== -1) {
const doubleQuoteIndex = tokenValue.indexOf('"');
const singleQuoteIndex = tokenValue.indexOf('\'');
const doubleQuoteExist = doubleQuoteIndex !== -1;
const singleQuoteExist = singleQuoteIndex !== -1;
if ((doubleQuoteExist && !singleQuoteExist) ||
(doubleQuoteExist && singleQuoteExist && doubleQuoteIndex < singleQuoteIndex)) {
// " is found and is in front of ' (if any)
lastQuotation = '"';
incompleteToken = true;
} else if (tokenValue.indexOf('\'') !== -1) {
} else if ((singleQuoteExist && !doubleQuoteExist) ||
(doubleQuoteExist && singleQuoteExist && singleQuoteIndex < doubleQuoteIndex)) {
// ' is found and is in front of " (if any)
lastQuotation = '\'';
incompleteToken = true;
}

View File

@ -242,14 +242,12 @@ describe 'Filter issues', feature: true do
end
it 'single quotes containing double quotes' do
# TODO: Actual bug
double_quotes_label = create(:label, project: project, title: 'won"t fix')
double_quotes_label_issue = create(:issue, title: "Issue with double quotes label", project: project)
double_quotes_label_issue.labels << double_quotes_label
# double_quotes_label = create(:label, project: project, title: 'won"t fix')
# double_quotes_label_issue = create(:issue, title: "Issue with double quotes label", project: project)
# double_quotes_label_issue.labels << double_quotes_label
# input_filtered_search("label:'#{double_quotes_label.title}'")
# expect_issues_list_count(1)
input_filtered_search("label:~'#{double_quotes_label.title}'")
expect_issues_list_count(1)
end
it 'double quotes containing single quotes' do