Skip to content

Commit c6fc5c2

Browse files
committed
extract html-removal from fastGetTrimmedText
1 parent 871ed96 commit c6fc5c2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/lib/html.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export function getTrimmedTextWithSpaces(elem: Object | Object[]): string {
3131
return getTextWithSpaces(elem).split(/\s+/).join(' ').trim()
3232
}
3333

34+
export function removeHtmlWithRegex(str: string): string {
35+
return str.replace(/<[^>]*>|\s+/g, ' ')
36+
}
37+
3438
export function fastGetTrimmedText(str: string): string {
35-
return str.replace(/<[^>]*>|\s+/g, ' ').replace(/\s+/g, ' ').trim()
39+
return removeHtmlWithRegex(str).replace(/\s+/g, ' ').trim()
3640
}

0 commit comments

Comments
 (0)