From ff087738fc5e0c402826591f2b985d9c866ff50c Mon Sep 17 00:00:00 2001 From: Dharini Date: Wed, 3 Sep 2025 09:12:12 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20parser=20for=20handling?= =?UTF-8?q?=20username=20with=20domain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../username_password_domain/index.js | 4 ++- .../username-password-domain-test.js | 36 +++++++++---------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/ui/admin/app/components/form/credential/username_password_domain/index.js b/ui/admin/app/components/form/credential/username_password_domain/index.js index 8afd432a0..2bcb24e90 100644 --- a/ui/admin/app/components/form/credential/username_password_domain/index.js +++ b/ui/admin/app/components/form/credential/username_password_domain/index.js @@ -40,7 +40,9 @@ export default class FormCredentialUsernamePasswordDomainComponent extends Compo // We let the server handle the validation in that case // and only update the model if we have exactly one username and one domain after splitting if (arr.length === 2) { - const [username, domain] = arr; + const isDomainFirst = value.includes('\\'); + const username = isDomainFirst ? arr[1] : arr[0]; + const domain = isDomainFirst ? arr[0] : arr[1]; // Update the model with the values only if both username and domain are present if (username && domain) { diff --git a/ui/admin/tests/integration/components/form/credential/username-password-domain-test.js b/ui/admin/tests/integration/components/form/credential/username-password-domain-test.js index 84274abc8..2b1adf108 100644 --- a/ui/admin/tests/integration/components/form/credential/username-password-domain-test.js +++ b/ui/admin/tests/integration/components/form/credential/username-password-domain-test.js @@ -18,8 +18,8 @@ module( test('it renders', async function (assert) { this.model = {}; - this.submit = () => { }; - this.cancel = () => { }; + this.submit = () => {}; + this.cancel = () => {}; await render( hbs``, ); @@ -35,8 +35,8 @@ module( test('it splits the username and domain when the value contains delimiters such as `@` or `\\` on `onBlur`', async function (assert) { this.model = { username: '', domain: '', authorized_actions: ['update'] }; - this.submit = () => { }; - this.cancel = () => { }; + this.submit = () => {}; + this.cancel = () => {}; await render(hbs` { }; - this.cancel = () => { }; + this.submit = () => {}; + this.cancel = () => {}; await render(hbs` { }; - this.cancel = () => { }; + this.submit = () => {}; + this.cancel = () => {}; await render(hbs` { }; - this.cancel = () => { }; + this.submit = () => {}; + this.cancel = () => {}; await render(hbs` { }; - this.cancel = () => { }; + this.submit = () => {}; + this.cancel = () => {}; await render(hbs` { }; - this.cancel = () => { }; + this.submit = () => {}; + this.cancel = () => {}; await render(hbs` { }; - this.cancel = () => { }; + this.submit = () => {}; + this.cancel = () => {}; await render(hbs` { }; + this.cancel = () => {}; await render(hbs`