~captainepoch/husky

76b2c95e8c35e274383073ce755673f7e7192d9f — Adolfo Santiago a month ago 7507a9c
Added String extension functions
1 files changed, 24 insertions(+), 0 deletions(-)

M husky/app/src/main/java/com/keylesspalace/tusky/core/extensions/StringExt.kt
M husky/app/src/main/java/com/keylesspalace/tusky/core/extensions/StringExt.kt => husky/app/src/main/java/com/keylesspalace/tusky/core/extensions/StringExt.kt +24 -0
@@ 22,6 22,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.
 *
 * @return String with zero-width space characters at start and end positions for emojis.