X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2Fshared%2Fangular%2Fhighlight.pipe.ts;h=50ee5c1bd372d9894baae059900ab334ec609f2d;hb=5fb2e2888ce032c638e4b75d07458642f0833e52;hp=fb604228024ef9eb2e8b813cf36f5f5d1dc46d21;hpb=1d17d86349fd2b3a9bc85145d02383ba4aea4dc0;p=github%2FChocobozzz%2FPeerTube.git
diff --git a/client/src/app/shared/angular/highlight.pipe.ts b/client/src/app/shared/angular/highlight.pipe.ts
index fb6042280..50ee5c1bd 100644
--- a/client/src/app/shared/angular/highlight.pipe.ts
+++ b/client/src/app/shared/angular/highlight.pipe.ts
@@ -11,19 +11,17 @@ export class HighlightPipe implements PipeTransform {
/* use this for global search */
static MULTI_MATCH = 'Multi-Match'
- // tslint:disable-next-line:no-empty
- constructor () {}
-
transform (
- contentString: string = null,
- stringToHighlight: string = null,
- option = 'Single-And-StartsWith-Match',
- caseSensitive = false,
- highlightStyleName = 'search-highlight'
+ contentString: string = null,
+ stringToHighlight: string = null,
+ option = 'Single-And-StartsWith-Match',
+ caseSensitive = false,
+ highlightStyleName = 'search-highlight'
): SafeHtml {
if (stringToHighlight && contentString && option) {
let regex: any = ''
const caseFlag: string = !caseSensitive ? 'i' : ''
+
switch (option) {
case 'Single-Match': {
regex = new RegExp(stringToHighlight, caseFlag)
@@ -42,10 +40,12 @@ export class HighlightPipe implements PipeTransform {
regex = new RegExp(stringToHighlight, 'gi')
}
}
+
const replaced = contentString.replace(
- regex,
- (match) => `${match}`
+ regex,
+ (match) => `${match}`
)
+
return replaced
} else {
return contentString