1
0
Fork 0
mirror of https://github.com/Corewala/Buran synced 2024-12-21 23:32:40 +00:00

Removed redundant ouri and fixed local redirects (again)

This commit is contained in:
Corewala 2022-07-29 16:21:00 -04:00
parent 319b0b4d14
commit 0ae42a214d
3 changed files with 6 additions and 14 deletions

View file

@ -70,10 +70,10 @@ class OmniTerm(private val listener: Listener) {
}
fun getGlobalUri(reference: String): String {
when {
reference.contains(":") -> return reference
reference.startsWith("//") -> return "gemini:$reference"
else -> return uri.resolve(reference)
return when {
reference.contains(":") -> reference
reference.startsWith("//") -> "gemini:$reference"
else -> uri.resolve(reference)
}
}

View file

@ -147,7 +147,7 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
when {
currentRequestAddress != uri.toString() -> {}
header.code == GeminiResponse.INPUT -> onUpdate(GemState.ResponseInput(uri, header))
header.code == GeminiResponse.REDIRECT -> onUpdate(GemState.Redirect(resolve(uri, header.meta)))
header.code == GeminiResponse.REDIRECT -> onUpdate(GemState.Redirect(header.meta))
header.code == GeminiResponse.CLIENT_CERTIFICATE_REQUIRED -> onUpdate(GemState.ClientCertRequired(uri, header))
header.code != GeminiResponse.SUCCESS -> onUpdate(GemState.ResponseError(header))
header.meta.startsWith("text/gemini") -> getGemtext(bufferedReader, requestEntity.trim().toURI(), header, onUpdate)
@ -173,8 +173,6 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
outWriter.close()
socket.close()
currentRequestAddress = null
}
private fun getGemtext(reader: BufferedReader, uri: URI, header: GeminiResponse.Header, onUpdate: (state: GemState) -> Unit){
@ -241,12 +239,6 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
}
}
private fun resolve(uri: URI, address: String): String{
val ouri = OppenURI()
ouri.set(uri.scheme + uri.host)
return ouri.resolve(address)
}
override fun canGoBack(): Boolean = runtimeHistory.isEmpty() || runtimeHistory.size > 1
//This just forces the factory to rebuild before the next request

View file

@ -458,7 +458,7 @@ class GemActivity : AppCompatActivity() {
.show()
}
is GemState.Redirect -> gemRequest(state.uri)
is GemState.Redirect -> gemRequest(omniTerm.getGlobalUri(state.uri))
is GemState.ClientCertRequired -> runOnUiThread {
loadingView(false)