Added String extension functions

This commit is contained in:
Adolfo Santiago 2021-11-21 18:17:46 +01:00
parent 7507a9cf16
commit 76b2c95e8c
No known key found for this signature in database
GPG Key ID: 244D6F9A317B4A65
1 changed files with 24 additions and 0 deletions

View File

@ -21,6 +21,30 @@ package com.keylesspalace.tusky.core.extensions
import java.util.regex.Pattern
/**
* Returns an empty String.
*
* @return An empty string.
*/
fun String.Companion.empty(): String {
return ""
}
/**
* Add https protocol to the URL.
*
* @return The url with https:// in front, null otherwise.
*/
fun String?.addHttpsProtocolUrl(): String {
if(this != null) {
if(!this.contains("https", true)) {
return ("https://$this")
}
}
return String.empty()
}
/**
* Returns the text with emojis and zero-width space characters at the start and end positions.
*