Skip to content

Commit

Permalink
Auto-remove trailing slash and other unwanted errors from Nightscout URL
Browse files Browse the repository at this point in the history
When users enter a trailing / in their Nightscout URL (Eg: "https://url/" rather than "https://url"), this will immediately result in a "Not found!" (404) error, because a / is already being appended. (Resulting in "https://url//").

This check removes the trailing slash to prevent 404's.
  • Loading branch information
LiroyvH committed May 15, 2024
1 parent f23b38a commit f902c73
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ extension NightscoutConfig {
}

func connect() {
if let CheckURL = url.last, CheckURL == "/" {
let fixedURL = url.dropLast()
url = String(fixedURL)
}
guard let url = URL(string: url) else {
message = "Invalid URL"
return
Expand Down

0 comments on commit f902c73

Please sign in to comment.