From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager] ui: pbs wizard: strip http(s):// prefix on remote creation
Date: Tue, 14 Oct 2025 09:11:42 +0200 [thread overview]
Message-ID: <20251014071221.454180-1-d.csapak@proxmox.com> (raw)
by reusing our 'normalize_hostname' helper. Move that to the remote
module, make it (crate) public, and use it for the case when we don't
have a nodes list (which is only pbs at the moment).
This strips the 'http(s)://' prefix when submitting the remote to the
backend, and preventing the 'invalid uri character' error there.
Reported in the forum:
https://forum.proxmox.com/threads/cant-add-proxmox-backup-server-node.173560/
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
ui/src/remotes/config.rs | 4 +++-
ui/src/remotes/mod.rs | 15 +++++++++++++++
ui/src/remotes/wizard_page_connect.rs | 16 ++--------------
3 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/ui/src/remotes/config.rs b/ui/src/remotes/config.rs
index c8c7815d..6e9ae490 100644
--- a/ui/src/remotes/config.rs
+++ b/ui/src/remotes/config.rs
@@ -7,6 +7,7 @@ use anyhow::Error;
use proxmox_schema::property_string::PropertyString;
use crate::remotes::edit_remote::EditRemote;
+use crate::remotes::normalize_hostname;
//use pwt::widget::form::{Field, FormContext, InputType};
use pdm_api_types::remotes::Remote;
@@ -50,8 +51,9 @@ async fn delete_item(key: Key) -> Result<(), Error> {
pub async fn create_remote(mut data: Value, remote_type: RemoteType) -> Result<(), Error> {
if data.get("nodes").is_none() {
+ let hostname = data["hostname"].as_str().unwrap_or_default().to_string();
let nodes = vec![PropertyString::new(NodeUrl {
- hostname: data["hostname"].as_str().unwrap_or_default().to_string(),
+ hostname: normalize_hostname(hostname),
fingerprint: data["fingerprint"].as_str().map(|fp| fp.to_string()),
})];
data["nodes"] = serde_json::to_value(nodes)?;
diff --git a/ui/src/remotes/mod.rs b/ui/src/remotes/mod.rs
index 83b3331b..fa091753 100644
--- a/ui/src/remotes/mod.rs
+++ b/ui/src/remotes/mod.rs
@@ -57,3 +57,18 @@ pub fn system_configuration() -> Html {
NavigationContainer::new().with_child(panel).into()
}
+
+/// normalize hostname for use in config
+pub(crate) fn normalize_hostname(hostname: String) -> String {
+ let mut result = hostname;
+ if let Some(hostname) = result.strip_prefix("http://") {
+ result = hostname.to_string();
+ }
+ if let Some(hostname) = result.strip_prefix("https://") {
+ result = hostname.to_string();
+ }
+ if let Some(hostname) = result.strip_suffix("/") {
+ result = hostname.to_string();
+ }
+ result
+}
diff --git a/ui/src/remotes/wizard_page_connect.rs b/ui/src/remotes/wizard_page_connect.rs
index bc45df61..9f5ba3ff 100644
--- a/ui/src/remotes/wizard_page_connect.rs
+++ b/ui/src/remotes/wizard_page_connect.rs
@@ -18,6 +18,8 @@ use pdm_api_types::remotes::{RemoteType, TlsProbeOutcome};
use pdm_api_types::CERT_FINGERPRINT_SHA256_SCHEMA;
use proxmox_acme_api::CertificateInfo;
+use crate::remotes::normalize_hostname;
+
#[derive(Clone, PartialEq, Properties)]
#[builder]
pub struct WizardPageConnect {
@@ -278,20 +280,6 @@ fn call_on_connect_change(props: &WizardPageConnect, certificate_info: Option<Ce
}
}
-fn normalize_hostname(hostname: String) -> String {
- let mut result = hostname;
- if let Some(hostname) = result.strip_prefix("http://") {
- result = hostname.to_string();
- }
- if let Some(hostname) = result.strip_prefix("https://") {
- result = hostname.to_string();
- }
- if let Some(hostname) = result.strip_suffix("/") {
- result = hostname.to_string();
- }
- result
-}
-
fn rows() -> Vec<KVGridRow> {
let render_date = |_name: &str, value: &Value, _record: &Value| -> Html {
match value.as_i64() {
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next reply other threads:[~2025-10-14 7:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 7:11 Dominik Csapak [this message]
2025-10-14 8:55 ` Christian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251014071221.454180-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox