Added String extension functions
This commit is contained in:
parent
7507a9cf16
commit
76b2c95e8c
1 changed files with 24 additions and 0 deletions
|
@ -21,6 +21,30 @@ package com.keylesspalace.tusky.core.extensions
|
||||||
|
|
||||||
import java.util.regex.Pattern
|
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.
|
* Returns the text with emojis and zero-width space characters at the start and end positions.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue