Skip to content

Commit df1398b

Browse files
authored
Merge pull request #249 from usnistgov/fix/ODD937-wrong-search-url
Fixed a bug when dealing with quotes
2 parents 673834a + 7b9735e commit df1398b

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

angular/src/app/shared/search-query/search-query.service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ export class SearchQueryService {
219219
buildQueryFromString(queryString: string, queryName?: string, fields?: SelectItem[]): SDPQuery{
220220
//Trim spaces
221221
queryString = queryString.replace(/\s+/g, ' ');
222-
223222
let lQueryName: string;
224223
//We are not going to save empty string
225224
if(!queryString){
@@ -239,15 +238,15 @@ export class SearchQueryService {
239238

240239
//Reserve everything in quotes
241240
let quotes = queryString.match(/\"(.*?)\"/g);
241+
242242
if(quotes){
243243
for(let i = 0; i < quotes.length; i++){
244244
if(quotes[i] != '""')
245-
queryString = queryString.replace(new RegExp(quotes[i].match(/\"(.*?)\"/)[1], 'g'), 'Quooooote'+("000" + i).slice(-3));
245+
queryString = queryString.replace(new RegExp('"' + quotes[i].match(/\"(.*?)\"/)[1] + '"', 'g'), 'Quooooote'+("000" + i).slice(-3));
246246
}
247247
}
248248

249249
let queryStringObject = this.parseQueryString(queryString);
250-
251250
//Restore everything in quotes to free text string
252251
if(quotes){
253252
for(let i = 0; i < quotes.length; i++){
@@ -261,7 +260,6 @@ export class SearchQueryService {
261260
let lKeyValuePair: string = queryStringObject.keyValuePairString;
262261
let query: SDPQuery = new SDPQuery(this.nextQueryId(), lQueryName);
263262
query.freeText = lFreeTextSearch.trim();
264-
265263
if(!this.isEmpty(lKeyValuePair)){
266264

267265
lKeyValuePair = lKeyValuePair.replace(new RegExp(' AND ', 'g'), '&AND&');
@@ -308,7 +306,7 @@ export class SearchQueryService {
308306
if(quotes){
309307
for(let i = 0; i < quotes.length; i++){
310308
if(quotes[i] != '""'){
311-
row.fieldText = row.fieldText.replace(new RegExp('Quooooote'+("000" + i).slice(-3), 'g'), quotes[i].match(/\"(.*?)\"/)[1]);
309+
row.fieldText = row.fieldText.replace(new RegExp('Quooooote'+("000" + i).slice(-3), 'g'), '"'+quotes[i].match(/\"(.*?)\"/)[1]+'"');
312310
}
313311
}
314312
}

0 commit comments

Comments
 (0)