Add HTTPS scheme when user enters a web address.

fork-5.53.8
Alex Hart 2022-03-24 16:53:06 -03:00 zatwierdzone przez Greyson Parrelli
rodzic 32d1cc7d54
commit af1701e6fa
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -43,7 +43,14 @@ class TextStoryPostLinkEntryFragment : KeyboardEntryDialogFragment(
input.addTextChangedListener(
afterTextChanged = {
linkPreviewViewModel.onTextChanged(requireContext(), it!!.toString(), input.selectionStart, input.selectionEnd)
val scheme = "https://"
val (uriString, selectionStart, selectionEnd) = if (it!!.startsWith(scheme)) {
Triple(it, input.selectionStart, input.selectionEnd)
} else {
Triple("$scheme$it", input.selectionStart + scheme.length, input.selectionEnd + scheme.length)
}
linkPreviewViewModel.onTextChanged(requireContext(), uriString.toString(), selectionStart, selectionEnd)
}
)