diff --git a/src/launchpad.cpp b/src/launchpad.cpp index 1eaaaa8..8b0ff4c 100644 --- a/src/launchpad.cpp +++ b/src/launchpad.cpp @@ -211,14 +211,14 @@ bool launchpad::is_authenticated() const { std::string launchpad::build_full_url(const std::string& endpoint) const { if (endpoint.rfind("http", 0) == 0) { return endpoint; - } else if (endpoint != "") { + } else if (!endpoint.empty()) { return service_root + "/" + api_version + "/" + endpoint; } std::cerr << "Internal error: endpoint is empty" << std::endl; return ""; } -std::optional launchpad::api_get(const std::string& endpoint, const std::map& params) const { +std::optional launchpad::api_get(const std::string endpoint, const std::map params) const { std::string url = build_full_url(endpoint); if (url.empty()) { if (!params.empty()) { @@ -296,10 +296,10 @@ std::optional launchpad::api_get(const std::string& endpoint, const } std::optional launchpad::api_post( - const std::string& endpoint, - const std::map& params, + const std::string endpoint, + const std::map params, bool build_endpoint, - const std::string& token_secret_override + const std::string token_secret_override ) { if (endpoint.empty()) { if (!params.empty()) { diff --git a/src/launchpad.h b/src/launchpad.h index 8791b6c..d842633 100644 --- a/src/launchpad.h +++ b/src/launchpad.h @@ -69,11 +69,11 @@ public: // API Methods std::optional get_archive(const std::string& distribution_name); - std::optional api_get(const std::string& endpoint = "", const std::map& params = {}) const; - std::optional api_post(const std::string& endpoint = "", - const std::map& params = {}, + std::optional api_get(const std::string endpoint = "", const std::map params = {}) const; + std::optional api_post(const std::string endpoint = "", + const std::map params = {}, bool build_endpoint = true, - const std::string& token_secret_override = ""); + const std::string token_secret_override = ""); std::optional api_patch(const std::string& endpoint = "", const nlohmann::json& data = nlohmann::json{}); std::optional api_delete(const std::string& endpoint = ""); diff --git a/src/source_package_publishing_history.cpp b/src/source_package_publishing_history.cpp index 3171e2a..5cc2023 100644 --- a/src/source_package_publishing_history.cpp +++ b/src/source_package_publishing_history.cpp @@ -82,6 +82,7 @@ void source_package_publishing_history::set_lp(launchpad* lp_ptr) { } const std::optional source_package_publishing_history::getDistroSeries() { + if (distro_series_link.empty()) return std::nullopt; auto response = lp->api_get(distro_series_link); if (!response) return std::nullopt; auto data = nlohmann::json::parse(response.value());