Commit 615c296 1 parent f840b7e commit 615c296 Copy full SHA for 615c296
File tree 1 file changed +6
-2
lines changed
app/src/main/java/com/infomaniak/mail/ui/newMessage
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -118,17 +118,21 @@ class InsertLinkDialog @Inject constructor(
118
118
}
119
119
120
120
private fun addMissingHttpsProtocol (link : String ): String {
121
- val protocolEndIndex = link.indexOf(" :// " )
121
+ val protocolEndIndex = link.indexOf(PROTOCOL_SEPARATOR )
122
122
val isProtocolSpecified = protocolEndIndex > 0 // If there is a specified protocol and it is at least 1 char long
123
123
124
124
if (isProtocolSpecified) return link
125
125
126
- val strippedUserInput = if (protocolEndIndex != - 1 ) link.substring(protocolEndIndex + 3 ) else link
126
+ val strippedUserInput = if (protocolEndIndex == - 1 ) link else link.substring( PROTOCOL_SEPARATOR .length)
127
127
128
128
return " https://$strippedUserInput "
129
129
}
130
130
131
131
private fun validate (userUrlInput : String ): Boolean {
132
132
return Patterns .WEB_URL .matcher(userUrlInput).matches()
133
133
}
134
+
135
+ companion object {
136
+ private const val PROTOCOL_SEPARATOR = " ://"
137
+ }
134
138
}
You can’t perform that action at this time.
0 commit comments