Skip to content

Commit

Permalink
PER-9353: Search with qutation marks
Browse files Browse the repository at this point in the history
Replaced the regex match that was removing all the qutation marks with a new function which removes only the first and last qutation marks.
  • Loading branch information
crisnicandrei committed Sep 21, 2023
1 parent fe4a97e commit 1d9b067
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app/search/services/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ export class SearchService {
const tagNames = part.match(getTagName) || [];
for (const tagName of tagNames) {
if (tagName) {
const name = tagName.replace(/"/g, '');
const name = this.removeFirstAndLastQuotes(tagName)
const tag = this.tags.getTagByName(name);
if (tag) {
parsedTags.push(tag);
}
}
}
if(!parsedTags.length){
queryString = termString;
}
} else {
queryParts.push(part);
}
Expand All @@ -80,9 +83,18 @@ export class SearchService {
} else {
queryString = termString;
}

return [queryString, parsedTags];
}

private removeFirstAndLastQuotes(str) {
if (str.startsWith('"')) {
str = str.substr(1);
}
if (str.endsWith('"')) {
str = str.substring(0, str.length - 1);
}
return str;
}

public getResultsInCurrentArchive(
searchTerm: string,
Expand Down

0 comments on commit 1d9b067

Please sign in to comment.