Skip to content

Commit

Permalink
Rename decodeUrlEncodedString to decodeHTMLString
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed May 15, 2024
1 parent 7806f53 commit 7616053
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import androidx.annotation.ChecksSdkIntAtLeast
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.S)
actual val canBlurImage: Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S

actual fun String.decodeUrlEncodedString(): String {
actual fun String.decodeHTMLString(): String {
return try {
Html.fromHtml(this, Html.FROM_HTML_MODE_COMPACT).toString()
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ package dev.sasikanth.rss.reader.util

expect val canBlurImage: Boolean

expect fun String.decodeUrlEncodedString(): String
expect fun String.decodeHTMLString(): String
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ actual val canBlurImage: Boolean = true

@OptIn(ExperimentalForeignApi::class, BetaInteropApi::class)
@Suppress("CAST_NEVER_SUCCEEDS")
actual fun String.decodeUrlEncodedString(): String {
actual fun String.decodeHTMLString(): String {
try {
val data = (this as NSString).dataUsingEncoding(NSUTF8StringEncoding)
if (data != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_SUM
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_TITLE
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_UPDATED
import dev.sasikanth.rss.reader.util.dateStringToEpochMillis
import dev.sasikanth.rss.reader.util.decodeUrlEncodedString
import dev.sasikanth.rss.reader.util.decodeHTMLString
import io.ktor.http.Url
import kotlinx.datetime.Clock
import org.kobjects.ktxml.api.EventType
Expand Down Expand Up @@ -85,8 +85,8 @@ internal object AtomContentParser : ContentParser() {
val iconUrl = FeedParser.feedIcon(host)

return FeedPayload(
name = FeedParser.cleanText(title ?: link)!!.decodeUrlEncodedString(),
description = FeedParser.cleanText(description).orEmpty().decodeUrlEncodedString(),
name = FeedParser.cleanText(title ?: link)!!.decodeHTMLString(),
description = FeedParser.cleanText(description).orEmpty().decodeHTMLString(),
icon = iconUrl,
homepageLink = link,
link = feedUrl,
Expand Down Expand Up @@ -149,8 +149,8 @@ internal object AtomContentParser : ContentParser() {

return PostPayload(
link = FeedParser.cleanText(link)!!,
title = FeedParser.cleanText(title).orEmpty().decodeUrlEncodedString(),
description = FeedParser.cleanTextCompact(content).orEmpty().decodeUrlEncodedString(),
title = FeedParser.cleanText(title).orEmpty().decodeHTMLString(),
description = FeedParser.cleanTextCompact(content).orEmpty().decodeHTMLString(),
rawContent = rawContent,
imageUrl = FeedParser.safeUrl(hostLink, image),
date = postPubDateInMillis ?: Clock.System.now().toEpochMilliseconds(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_RSS
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_TITLE
import dev.sasikanth.rss.reader.core.network.parser.FeedParser.Companion.TAG_URL
import dev.sasikanth.rss.reader.util.dateStringToEpochMillis
import dev.sasikanth.rss.reader.util.decodeUrlEncodedString
import dev.sasikanth.rss.reader.util.decodeHTMLString
import io.ktor.http.Url
import kotlinx.datetime.Clock
import org.kobjects.ktxml.api.EventType
Expand Down Expand Up @@ -89,8 +89,8 @@ internal object RssContentParser : ContentParser() {
val iconUrl = FeedParser.feedIcon(host)

return FeedPayload(
name = FeedParser.cleanText(title ?: link)!!.decodeUrlEncodedString(),
description = FeedParser.cleanText(description).orEmpty().decodeUrlEncodedString(),
name = FeedParser.cleanText(title ?: link)!!.decodeHTMLString(),
description = FeedParser.cleanText(description).orEmpty().decodeHTMLString(),
icon = iconUrl,
homepageLink = link,
link = feedUrl,
Expand Down Expand Up @@ -157,8 +157,8 @@ internal object RssContentParser : ContentParser() {

return PostPayload(
link = FeedParser.cleanText(link)!!,
title = FeedParser.cleanText(title).orEmpty().decodeUrlEncodedString(),
description = FeedParser.cleanTextCompact(description).orEmpty().decodeUrlEncodedString(),
title = FeedParser.cleanText(title).orEmpty().decodeHTMLString(),
description = FeedParser.cleanTextCompact(description).orEmpty().decodeHTMLString(),
rawContent = rawContent,
imageUrl = FeedParser.safeUrl(hostLink, image),
date = postPubDateInMillis ?: Clock.System.now().toEpochMilliseconds(),
Expand Down

0 comments on commit 7616053

Please sign in to comment.