From 9e6fb95e0f1ba39ac953dedd3c6d7d15c9869092 Mon Sep 17 00:00:00 2001 From: Dave Allie Date: Wed, 14 Jan 2026 22:46:01 +1100 Subject: [PATCH] Move isHttpsUrl to UrlUtils --- src/network/HttpDownloader.cpp | 8 +++----- src/util/UrlUtils.cpp | 2 ++ src/util/UrlUtils.h | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/network/HttpDownloader.cpp b/src/network/HttpDownloader.cpp index b52ded8..c4de3a0 100644 --- a/src/network/HttpDownloader.cpp +++ b/src/network/HttpDownloader.cpp @@ -7,14 +7,12 @@ #include -namespace { -bool isHttpsUrl(const std::string& url) { return url.rfind("https://", 0) == 0; } -} // namespace +#include "util/UrlUtils.h" bool HttpDownloader::fetchUrl(const std::string& url, std::string& outContent) { // Use WiFiClientSecure for HTTPS, regular WiFiClient for HTTP std::unique_ptr client; - if (isHttpsUrl(url)) { + if (UrlUtils::isHttpsUrl(url)) { auto* secureClient = new WiFiClientSecure(); secureClient->setInsecure(); client.reset(secureClient); @@ -47,7 +45,7 @@ HttpDownloader::DownloadError HttpDownloader::downloadToFile(const std::string& ProgressCallback progress) { // Use WiFiClientSecure for HTTPS, regular WiFiClient for HTTP std::unique_ptr client; - if (isHttpsUrl(url)) { + if (UrlUtils::isHttpsUrl(url)) { auto* secureClient = new WiFiClientSecure(); secureClient->setInsecure(); client.reset(secureClient); diff --git a/src/util/UrlUtils.cpp b/src/util/UrlUtils.cpp index 0eeeae3..bbf5ac1 100644 --- a/src/util/UrlUtils.cpp +++ b/src/util/UrlUtils.cpp @@ -2,6 +2,8 @@ namespace UrlUtils { +bool isHttpsUrl(const std::string& url) { return url.rfind("https://", 0) == 0; } + std::string ensureProtocol(const std::string& url) { if (url.find("://") == std::string::npos) { return "http://" + url; diff --git a/src/util/UrlUtils.h b/src/util/UrlUtils.h index d88ca13..6428161 100644 --- a/src/util/UrlUtils.h +++ b/src/util/UrlUtils.h @@ -3,6 +3,11 @@ namespace UrlUtils { +/** + * Check if URL uses HTTPS protocol + */ +bool isHttpsUrl(const std::string& url); + /** * Prepend http:// if no protocol specified (server will redirect to https if needed) */