Skip to content

Commit 8046128

Browse files
fix:Incomplete string escaping or encoding #709 (#723)
* fix:Incomplete string escaping or encoding #709 add additional methods to extracts blogs' text content within paragraph tags'.And tested. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8bb65dc commit 8046128

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/containers/blogs/Blogs.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ export default function Blogs() {
1414
function extractTextContent(html) {
1515
return typeof html === "string"
1616
? html
17-
.split("p>")
18-
.filter(el => !el.includes(">"))
19-
.map(el => el.replace("</", ".").replace("<", ""))
17+
.split(/<\/p>/i)
18+
.map(part => part.split(/<p[^>]*>/i).pop())
19+
.filter(el => el.trim().length > 0)
20+
.map(el => el.replace(/<\/?[^>]+(>|$)/g, "").trim())
2021
.join(" ")
2122
: NaN;
2223
}

0 commit comments

Comments
 (0)