Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion plugins/updater/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl Updater {
let mut raw_json: Option<serde_json::Value> = None;
let mut last_error: Option<Error> = None;
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
// https://releases.myapp.com/update/{{target}}/{{arch}}/{{current_version}}
// will be translated into ->
Expand All @@ -404,17 +404,22 @@ impl Updater {
const CONTROLS_ADD: &AsciiSet = &CONTROLS.add(b'+');
let encoded_version = percent_encoding::percent_encode(version, CONTROLS_ADD);
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
.to_string()
// url::Url automatically url-encodes the path components
.replace("%7B%7Bcurrent_version%7D%7D", &encoded_version)
.replace("%7B%7Btarget%7D%7D", target)
.replace("%7B%7Barch%7D%7D", self.arch)
.replace("%7B%7Bbundle_type%7D%7D", installer)
// but not query parameters
.replace("{{current_version}}", &encoded_version)
.replace("{{target}}", target)
.replace("{{arch}}", self.arch)
.replace("{{bundle_type}}", installer)
.parse()?;

log::debug!("checking for updates {url}");
Expand Down
Loading