mirror of
https://github.com/Corewala/Buran
synced 2024-12-22 07:42:43 +00:00
Made relative query strings work in accordance with the URL spec
This commit is contained in:
parent
f89f41ae14
commit
eee109bb28
1 changed files with 11 additions and 1 deletions
|
@ -6,6 +6,7 @@ const val GEMSCHEME = "gemini://"
|
|||
const val TRAVERSE = "../"
|
||||
const val SOLIDUS = "/"
|
||||
const val DIREND = "/"
|
||||
const val QUERY = "?"
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -44,9 +45,18 @@ class OppenURI constructor(private var ouri: String) {
|
|||
val traversalCount = reference.split(TRAVERSE).size - 1
|
||||
ouri = traverse(traversalCount) + reference.replace(TRAVERSE, "")
|
||||
}
|
||||
reference.startsWith(QUERY) -> {
|
||||
ouri = if(reference.contains(QUERY)){
|
||||
ouri.substringBefore(QUERY) + reference
|
||||
}else{
|
||||
ouri + reference
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
ouri = when {
|
||||
ouri.endsWith(DIREND) -> "${ouri}$reference"
|
||||
ouri.endsWith(DIREND) -> {
|
||||
"${ouri}$reference"
|
||||
}
|
||||
else -> "${ouri.substring(0, ouri.lastIndexOf("/"))}/$reference"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue