Skip to content

Commit 8cf8eea

Browse files
authored
feat(updater): inject bundle_type into endpoint url (#2960)
* feat(updater): inject bundle_type into endpoint url * Revert schemas * replace with unknown if none
1 parent 509eba8 commit 8cf8eea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugins/updater/src/updater.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl Updater {
392392
let mut raw_json: Option<serde_json::Value> = None;
393393
let mut last_error: Option<Error> = None;
394394
for url in &self.endpoints {
395-
// replace {{current_version}}, {{target}} and {{arch}} in the provided URL
395+
// replace {{current_version}}, {{target}}, {{arch}} and {{bundle_type}} in the provided URL
396396
// this is useful if we need to query example
397397
// https://releases.myapp.com/update/{{target}}/{{arch}}/{{current_version}}
398398
// will be translated into ->
@@ -404,17 +404,22 @@ impl Updater {
404404
const CONTROLS_ADD: &AsciiSet = &CONTROLS.add(b'+');
405405
let encoded_version = percent_encoding::percent_encode(version, CONTROLS_ADD);
406406
let encoded_version = encoded_version.to_string();
407+
let installer = installer_for_bundle_type(bundle_type())
408+
.map(|i| i.name())
409+
.unwrap_or("unknown");
407410

408411
let url: Url = url
409412
.to_string()
410413
// url::Url automatically url-encodes the path components
411414
.replace("%7B%7Bcurrent_version%7D%7D", &encoded_version)
412415
.replace("%7B%7Btarget%7D%7D", target)
413416
.replace("%7B%7Barch%7D%7D", self.arch)
417+
.replace("%7B%7Bbundle_type%7D%7D", installer)
414418
// but not query parameters
415419
.replace("{{current_version}}", &encoded_version)
416420
.replace("{{target}}", target)
417421
.replace("{{arch}}", self.arch)
422+
.replace("{{bundle_type}}", installer)
418423
.parse()?;
419424

420425
log::debug!("checking for updates {url}");

0 commit comments

Comments
 (0)