Cleanup.
This commit is contained in:
parent
0e6d9921f6
commit
2db72fa867
1 changed files with 11 additions and 8 deletions
|
@ -37,6 +37,13 @@ import kotlinx.serialization.json.Json
|
|||
import kotlinx.serialization.json.JsonConfiguration
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
|
||||
private fun String?.ifNull(): String {
|
||||
if (this == null) {
|
||||
return ""
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* A comment to send to Akismet.
|
||||
*
|
||||
|
@ -185,7 +192,10 @@ open class AkismetComment(val userIp: String, val userAgent: String) {
|
|||
*
|
||||
* @see [serverEnv]
|
||||
*/
|
||||
constructor(request: HttpServletRequest) : this(request.remoteAddr.ifNull(), request.getHeader("User-Agent").ifNull()) {
|
||||
constructor(request: HttpServletRequest) : this(
|
||||
request.remoteAddr.ifNull(),
|
||||
request.getHeader("User-Agent").ifNull()
|
||||
) {
|
||||
referrer = request.getHeader("referer").ifNull()
|
||||
serverEnv = buildServerEnv(request)
|
||||
}
|
||||
|
@ -274,10 +284,3 @@ private fun buildServerEnv(request: HttpServletRequest): HashMap<String, String>
|
|||
|
||||
return params
|
||||
}
|
||||
|
||||
private fun String.ifNull(): String {
|
||||
if (this == null) {
|
||||
return ""
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue