From 3868e136a61283b879b4507d24171850ec2d2a29 Mon Sep 17 00:00:00 2001 From: Kim Minh Kaplan Date: Mon, 27 Mar 2023 09:51:24 +0000 Subject: [PATCH] [bugfix] Login::new(): do not emit a svcExtension element if ext_uris is None or empty. Fixes issue #94. --- src/login.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/login.rs b/src/login.rs index a1fda65..9a0bd53 100644 --- a/src/login.rs +++ b/src/login.rs @@ -36,7 +36,12 @@ impl<'a> Login<'a> { new_password: Option<&'a str>, ext_uris: Option<&'_ [&'a str]>, ) -> Self { - let ext_uris = ext_uris.map(|uris| uris.iter().map(|&u| u.into()).collect()); + let svc_ext = match ext_uris { + Some(uris) if ! uris.is_empty() => Some(ServiceExtension { + ext_uris: Some(uris.iter().map(|&u| u.into()).collect()) + }), + _ => None + }; Self { username: username.into(), @@ -52,7 +57,7 @@ impl<'a> Login<'a> { contact::XMLNS.into(), domain::XMLNS.into(), ], - svc_ext: Some(ServiceExtension { ext_uris }), + svc_ext }, } }