feat(updater): inject bundle_type into endpoint url (#2960)

* feat(updater): inject bundle_type into endpoint url

* Revert schemas

* replace with unknown if none
This commit is contained in:
Fabian-Lars
2025-08-27 15:52:17 -03:00
committed by GitHub
parent 509eba8d44
commit 8cf8eeab02
+6 -1
View File
@@ -392,7 +392,7 @@ impl Updater {
let mut raw_json: Option<serde_json::Value> = None; let mut raw_json: Option<serde_json::Value> = None;
let mut last_error: Option<Error> = None; let mut last_error: Option<Error> = None;
for url in &self.endpoints { for url in &self.endpoints {
// replace {{current_version}}, {{target}} and {{arch}} in the provided URL // replace {{current_version}}, {{target}}, {{arch}} and {{bundle_type}} in the provided URL
// this is useful if we need to query example // this is useful if we need to query example
// https://releases.myapp.com/update/{{target}}/{{arch}}/{{current_version}} // https://releases.myapp.com/update/{{target}}/{{arch}}/{{current_version}}
// will be translated into -> // will be translated into ->
@@ -404,6 +404,9 @@ impl Updater {
const CONTROLS_ADD: &AsciiSet = &CONTROLS.add(b'+'); const CONTROLS_ADD: &AsciiSet = &CONTROLS.add(b'+');
let encoded_version = percent_encoding::percent_encode(version, CONTROLS_ADD); let encoded_version = percent_encoding::percent_encode(version, CONTROLS_ADD);
let encoded_version = encoded_version.to_string(); let encoded_version = encoded_version.to_string();
let installer = installer_for_bundle_type(bundle_type())
.map(|i| i.name())
.unwrap_or("unknown");
let url: Url = url let url: Url = url
.to_string() .to_string()
@@ -411,10 +414,12 @@ impl Updater {
.replace("%7B%7Bcurrent_version%7D%7D", &encoded_version) .replace("%7B%7Bcurrent_version%7D%7D", &encoded_version)
.replace("%7B%7Btarget%7D%7D", target) .replace("%7B%7Btarget%7D%7D", target)
.replace("%7B%7Barch%7D%7D", self.arch) .replace("%7B%7Barch%7D%7D", self.arch)
.replace("%7B%7Bbundle_type%7D%7D", installer)
// but not query parameters // but not query parameters
.replace("{{current_version}}", &encoded_version) .replace("{{current_version}}", &encoded_version)
.replace("{{target}}", target) .replace("{{target}}", target)
.replace("{{arch}}", self.arch) .replace("{{arch}}", self.arch)
.replace("{{bundle_type}}", installer)
.parse()?; .parse()?;
log::debug!("checking for updates {url}"); log::debug!("checking for updates {url}");