NSCv3: strip trailing slash from url

This commit is contained in:
Milos Kozak 2023-01-12 16:10:23 +01:00
parent 6fb8339238
commit 87ca7ef6cf
5 changed files with 9 additions and 7 deletions

View file

@ -9,12 +9,13 @@ import java.io.File
import javax.inject.Inject
import javax.inject.Singleton
@Suppress("KotlinConstantConditions")
@Singleton
class ConfigImpl @Inject constructor(
fileListProvider: PrefFileListProvider
) : Config {
override val SUPPORTEDNSVERSION = 140206 // 14.2.6
override val SUPPORTED_NS_VERSION = 140206 // 14.2.6
override val APS = BuildConfig.FLAVOR == "full"
override val NSCLIENT = BuildConfig.FLAVOR == "aapsclient" || BuildConfig.FLAVOR == "aapsclient2"
override val PUMPCONTROL = BuildConfig.FLAVOR == "pumpcontrol"

View file

@ -2,7 +2,7 @@ package info.nightscout.interfaces
@Suppress("PropertyName")
interface Config {
val SUPPORTEDNSVERSION: Int
val SUPPORTED_NS_VERSION: Int
val APS: Boolean
val NSCLIENT: Boolean
val PUMPCONTROL: Boolean

View file

@ -1,3 +1,5 @@
@file:Suppress("SpellCheckingInspection")
package info.nightscout.plugins.sync.nsclient.data
import android.content.Context
@ -63,7 +65,7 @@ import javax.inject.Singleton
"showForecast": "ar2",
"focusHours": 3,
"heartbeat": 60,
"baseURL": "http:\/\/barascgm.sysop.cz:82",
"baseURL": "http:\/\/xxxxxxxxxxxx",
"authDefaultRoles": "readable",
"thresholds": {
"bgHigh": 252,
@ -150,7 +152,7 @@ class NSSettingsStatusImpl @Inject constructor(
override fun handleNewData(status: JSONObject) {
data = status
aapsLogger.debug(LTag.NSCLIENT, "Got versions: Nightscout: ${getVersion()}")
if (getVersionNum() < config.SUPPORTEDNSVERSION) {
if (getVersionNum() < config.SUPPORTED_NS_VERSION) {
uiInteraction.addNotification(Notification.OLD_NS, rh.gs(R.string.unsupported_ns_version), Notification.NORMAL)
} else {
rxBus.send(EventDismissNotification(Notification.OLD_NS))
@ -177,7 +179,7 @@ class NSSettingsStatusImpl @Inject constructor(
JsonHelper.safeGetJSONObject(data, "extendedSettings", null)
// valid property is "warn" or "urgent"
// plugings "iage" "sage" "cage" "pbage"
// plugins "iage" "sage" "cage" "pbage"
private fun getExtendedWarnValue(plugin: String, property: String): Double? {
val extendedSettings = getExtendedSettings() ?: return null
val pluginJson = extendedSettings.optJSONObject(plugin) ?: return null

View file

@ -17,7 +17,6 @@ import info.nightscout.shared.utils.T
import javax.inject.Inject
import javax.inject.Singleton
@Suppress("SpellCheckingInspection")
@Singleton
class ProcessedDeviceStatusDataImpl @Inject constructor(
private val rh: ResourceHelper,

View file

@ -251,7 +251,7 @@ class NSClientV3Plugin @Inject constructor(
private fun setClient() {
nsAndroidClient = NSAndroidClientImpl(
baseUrl = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace("https://", ""),
baseUrl = sp.getString(info.nightscout.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace("https://", "").replace(Regex("/$"), ""),
accessToken = sp.getString(R.string.key_ns_client_token, ""),
context = context,
logging = true