From 37becd5949807f0b39f21753f1a1cc4f274bbf6e Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Tue, 12 Jul 2022 17:44:25 +0300 Subject: [PATCH] Remove double quotes in case of forced double quotes. Fix parenthesis in quotes queries --- searchPages/searchUtils/newSearchPage.component.ts | 10 ++++++---- timeout-interceptor.service.ts | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index 513a5648..586f9ae5 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -990,7 +990,7 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges { } } if (doisParams.length > 0) { - params += "(" + this.createQuotedKeywordQuery(value, id, operatorId, countParams, true, true) + " or " + doisParams + ")"; + params += this.createQuotedKeywordQuery(value, id, operatorId, countParams, true, true) + " or " + doisParams + ")"; } else { //if it is PIDs but no doisquery produced, forced to use quotes as the query will fail due to special characters params += this.createQuotedKeywordQuery(value, id, operatorId, countParams, true, @@ -1003,7 +1003,7 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges { } - private static createQuotedKeywordQuery(fieldValue, fieldId, fieldOperator, countParams: number, isSearchAll: boolean, forceQuotted: boolean = false) { + private static createQuotedKeywordQuery(fieldValue: string, fieldId, fieldOperator, countParams: number, isSearchAll: boolean, forceQuotted: boolean = false) { let params = ""; let countQuote = (fieldValue.match(/'/g) || []).length; let countDoubleQuote = (fieldValue.match(/"/g) || []).length; @@ -1014,7 +1014,9 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges { params += (countParams == 0 ? "" : fieldOperator); params += " ("; if (forceQuotted) { - return (countParams == 0 ? "" : " " + fieldOperator + " ") + this.getQuotedQueryPart(fieldId, '"' + fieldValue + '"', isSearchAll); + /** Remove double quotes **/ + fieldValue = fieldValue.replace(/["]+/g, ''); + return (countParams == 0 ? "" : " " + fieldOperator + " (") + this.getQuotedQueryPart(fieldId, '"' + fieldValue + '"', isSearchAll); } if (quotedParts && quotedParts.length == 1 && quotedParts[0] == fieldValue) { params += this.getQuotedQueryPart(fieldId, fieldValue, isSearchAll); @@ -1068,7 +1070,7 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges { i++; } } - return query + return query; } private static checkForReservedWords(keyword: string) { diff --git a/timeout-interceptor.service.ts b/timeout-interceptor.service.ts index c1374c82..f4737a45 100644 --- a/timeout-interceptor.service.ts +++ b/timeout-interceptor.service.ts @@ -4,7 +4,6 @@ import { Observable } from 'rxjs'; import { timeout } from 'rxjs/operators'; import {isPlatformServer} from "@angular/common"; import {properties} from "../../environments/environment"; -import {isArray} from "util"; export const DEFAULT_TIMEOUT = new InjectionToken('defaultTimeout');