Skip to content

Commit

Permalink
fix:Incomplete string escaping or encoding #709 (#723)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
TheinSoe137 and pre-commit-ci[bot] authored Oct 18, 2024
1 parent 8bb65dc commit 8046128
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/containers/blogs/Blogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export default function Blogs() {
function extractTextContent(html) {
return typeof html === "string"
? html
.split("p>")
.filter(el => !el.includes(">"))
.map(el => el.replace("</", ".").replace("<", ""))
.split(/<\/p>/i)
.map(part => part.split(/<p[^>]*>/i).pop())
.filter(el => el.trim().length > 0)
.map(el => el.replace(/<\/?[^>]+(>|$)/g, "").trim())
.join(" ")
: NaN;
}
Expand Down

0 comments on commit 8046128

Please sign in to comment.