Fixed sharing of relative links

This commit is contained in:
Corewala 2022-07-29 15:47:33 -04:00
parent 13f21bc09b
commit 319b0b4d14
3 changed files with 9 additions and 7 deletions

View File

@ -58,7 +58,6 @@ class OmniTerm(private val listener: Listener) {
link.startsWith("//") -> uri.set("gemini:$link")
link.startsWith("http://") or link.startsWith("https://") -> {
uri.set(link)
println("MALD?")
}
link.contains(":") -> listener.openExternal(link)
else -> uri.resolve(link)
@ -70,6 +69,14 @@ class OmniTerm(private val listener: Listener) {
println("OmniTerm resolved address: $address")
}
fun getGlobalUri(reference: String): String {
when {
reference.contains(":") -> return reference
reference.startsWith("//") -> return "gemini:$reference"
else -> return uri.resolve(reference)
}
}
fun reset(){
uri = penultimate.copy()
}

View File

@ -36,7 +36,6 @@ class OppenURI constructor(private var ouri: String) {
fun resolve(reference: String): String{
if(ouri == "$GEMSCHEME$host") ouri = "$ouri/"
println(host)
when {
reference.startsWith(GEMSCHEME) -> set(reference)
reference.startsWith(SOLIDUS) -> ouri = "$scheme://$host$reference"

View File

@ -97,11 +97,7 @@ class GemActivity : AppCompatActivity() {
private val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit = { uri, longTap, _: Int ->
if(longTap){
val globalURI = if(!uri.toString().contains("//") and !uri.toString().contains(":")){
(omniTerm.getCurrent() + uri.toString()).replace("//", "/").replace(":/", "://")
} else {
uri.toString()
}
val globalURI = omniTerm.getGlobalUri(uri.toString())
Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, globalURI)