Skip to content

Commit

Permalink
fix: better support split search for using more complex query paramet…
Browse files Browse the repository at this point in the history
…ers.
  • Loading branch information
plateaukao committed Jun 3, 2024
1 parent ce0aca5 commit 6e1fdb8
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ package info.plateaukao.einkbro.viewmodel
import androidx.lifecycle.ViewModel
import java.net.URLEncoder

class SplitSearchViewModel: ViewModel() {
class SplitSearchViewModel : ViewModel() {
var state: ActionModeMenuState.SplitSearch? = null

fun reset() {
state = null
}
fun getUrl(text: String): String =
state?.stringFormat?.format(URLEncoder.encode(text , "UTF-8")) ?: ""

fun getUrl(text: String): String {
val stringFormat = state?.stringFormat ?: return ""
if (stringFormat.contains("=")) {
val url = stringFormat.format(text, "UTF-8")
return url.split("=")[0] + "=" +
URLEncoder.encode(url.split("=")[1], "UTF-8")
} else {
return state?.stringFormat?.format(URLEncoder.encode(text, "UTF-8")) ?: ""
}
}
}

0 comments on commit 6e1fdb8

Please sign in to comment.