Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion LoopFollow/Helpers/NightscoutUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ class NightscoutUtils {
queryItems.append(URLQueryItem(name: key, value: value))
}

components?.queryItems = queryItems
// Assigning an empty array would still append a bare "?" to the URL.
if !queryItems.isEmpty {
components?.queryItems = queryItems
}

return components?.url
}
Expand Down
14 changes: 6 additions & 8 deletions LoopFollow/ViewControllers/NightScoutViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ class NightscoutViewController: UIViewController {
}
.store(in: &cancellables)

var url = Storage.shared.url.value
let token = Storage.shared.token.value

if token != "" {
url = url + "?token=" + token
}

guard let myUrl = URL(string: url) else { return }
guard let myUrl = NightscoutUtils.constructURL(
baseURL: Storage.shared.url.value,
token: Storage.shared.token.value,
endpoint: "",
parameters: [:]
) else { return }

let webpagePreferences = WKWebpagePreferences()
webpagePreferences.allowsContentJavaScript = true
Expand Down
Loading