This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from SaltyNote/cleanup
cleanup
- Loading branch information
Showing
3 changed files
with
20 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,30 @@ | ||
package com.saltynote.service.utils | ||
|
||
import com.saltynote.service.exception.IllegalInitialException | ||
import org.apache.commons.lang3.StringUtils | ||
|
||
class BaseUtils private constructor() { | ||
init { | ||
throw IllegalInitialException("Do not instantiate me.") | ||
} | ||
|
||
companion object { | ||
private var baseUrl = "https://saltynote.com" | ||
object BaseUtils { | ||
private var baseUrl = "https://saltynote.com" | ||
|
||
// This is used for test or dev usage, do not call it in prod. | ||
fun setBaseUrl(baseUrl: String) { | ||
if (StringUtils.startsWithIgnoreCase(baseUrl, "http")) { | ||
Companion.baseUrl = baseUrl | ||
} | ||
// This is used for test or dev usage, do not call it in prod. | ||
fun setBaseUrl(baseUrl: String) { | ||
if (StringUtils.startsWithIgnoreCase(baseUrl, "http")) { | ||
BaseUtils.baseUrl = baseUrl | ||
} | ||
} | ||
|
||
fun getPasswordResetUrl(secret: String): String { | ||
return "$baseUrl/password/reset?token=$secret" | ||
} | ||
fun getPasswordResetUrl(secret: String): String { | ||
return "$baseUrl/password/reset?token=$secret" | ||
} | ||
|
||
fun containsAllIgnoreCase(src: String, queries: Iterable<String>): Boolean { | ||
if (StringUtils.isBlank(src)) { | ||
fun containsAllIgnoreCase(src: String, queries: Iterable<String>): Boolean { | ||
if (StringUtils.isBlank(src)) { | ||
return false | ||
} | ||
for (q in queries) { | ||
if (StringUtils.isNotBlank(q) && !StringUtils.containsIgnoreCase(src, q.trim { it <= ' ' })) { | ||
return false | ||
} | ||
for (q in queries) { | ||
if (StringUtils.isNotBlank(q) && !StringUtils.containsIgnoreCase(src, q.trim { it <= ' ' })) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
return true | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
src/test/kotlin/com/saltynote/service/utils/BaseUtilsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters