Merge branch 'master' into refactor/split_lib_app

This commit is contained in:
Adam 2023-06-04 20:40:23 +02:00
commit 231bca79fb

View file

@ -59,7 +59,7 @@ object UrlEncoderUtil {
// see https://www.rfc-editor.org/rfc/rfc3986#page-13
// and https://url.spec.whatwg.org/#application-x-www-form-urlencoded-percent-encode-set
private fun Char.isUnreserved(): Boolean {
return this <= 'z' && unreservedChars.get(code)
return this <= 'z' && unreservedChars[code]
}
private fun StringBuilder.appendEncodedDigit(digit: Int) {
@ -165,19 +165,22 @@ object UrlEncoderUtil {
out.append(source, 0, i)
}
val cp = source.codePointAt(i)
if (cp < 0x80) {
when {
cp < 0x80 -> {
if (spaceToPlus && ch == ' ') {
out.append('+')
} else {
out.appendEncodedByte(cp)
}
i++
} else if (Character.isBmpCodePoint(cp)) {
}
Character.isBmpCodePoint(cp) -> {
for (b in ch.toString().toByteArray(StandardCharsets.UTF_8)) {
out.appendEncodedByte(b.toInt())
}
i++
} else if (Character.isSupplementaryCodePoint(cp)) {
}
Character.isSupplementaryCodePoint(cp) -> {
val high = Character.highSurrogate(cp)
val low = Character.lowSurrogate(cp)
for (b in charArrayOf(high, low).concatToString().toByteArray(StandardCharsets.UTF_8)) {
@ -187,6 +190,7 @@ object UrlEncoderUtil {
}
}
}
}
return out?.toString() ?: source
}