Skip to content

Commit

Permalink
deal with doupache's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
wusamzong committed Nov 29, 2023
1 parent 8e7780b commit 9d55987
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app/components/nodes-view/highlighttable-search.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { Pipe, PipeTransform } from '@angular/core';
export class HighlightSearchPipe implements PipeTransform {

transform(value: string, search: string): string {
const valueStr = value + ''; // Ensure numeric values are converted to strings
const valueStr = String(value); // Ensure numeric values are converted to strings
// (?![^&;]+;) - to ensure that there are no HTML entities (such as & or <)
// ex. value = "<span>" search = "span", The word 'span' will not be included in the matches
// (?!<[^<>]*) - to ensure that there are no HTML tags (<...>)
// ex. value = "<span>" search = "span", The word 'span' will not be included in the matches
return valueStr.replace(new RegExp('(?![^&;]+;)(?!<[^<>]*)(' + search + ')(?![^<>]*>)(?![^&;]+;)', 'gi'), '<strong>$1</strong>');
}

Expand Down

0 comments on commit 9d55987

Please sign in to comment.