From d879919d759866f8765e1a41224c5ce3db4e539a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 9 Jan 2025 14:29:49 +0100 Subject: [PATCH] correct path generation --- .../contexts/route-path-addendum.context.ts | 3 ++- .../contexts/route-path-addendum.test.ts | 24 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/router/contexts/route-path-addendum.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/router/contexts/route-path-addendum.context.ts index 4000c8bad2..9099054098 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/router/contexts/route-path-addendum.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/router/contexts/route-path-addendum.context.ts @@ -34,6 +34,7 @@ export class UmbRoutePathAddendumContext if (this.#parentAddendum === undefined || this.#currentAddendum === undefined) { return; } - this.#pathAddendum.setValue(this.#parentAddendum + this.#currentAddendum); + const base = this.#parentAddendum === '' ? this.#parentAddendum : this.#parentAddendum + '/'; + this.#pathAddendum.setValue(base + this.#currentAddendum); } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/router/contexts/route-path-addendum.test.ts b/src/Umbraco.Web.UI.Client/src/packages/core/router/contexts/route-path-addendum.test.ts index 82217e27f0..2a9582aac5 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/router/contexts/route-path-addendum.test.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/router/contexts/route-path-addendum.test.ts @@ -60,11 +60,11 @@ describe('UmbRoutepathAddendum', () => { it('returns late set addendum', (done) => { addendumContext.observe(addendumContext.addendum, (addendum) => { if (addendum) { - expect(addendum).to.equal('/hello/here'); + expect(addendum).to.equal('hello/here'); done(); } }); - addendumContext.setAddendum('/hello/here'); + addendumContext.setAddendum('hello/here'); }); it('returns an updated addendum', (done) => { @@ -73,49 +73,49 @@ describe('UmbRoutepathAddendum', () => { count++; if (count === 1) { if (addendum) { - expect(addendum).to.equal('/hello/here'); + expect(addendum).to.equal('hello/here'); done(); } } else if (count === 2) { if (addendum) { - expect(addendum).to.equal('/hello/updateded'); + expect(addendum).to.equal('hello/updateded'); done(); } } }); - addendumContext.setAddendum('/hello/here'); - addendumContext.setAddendum('/hello/updateded'); + addendumContext.setAddendum('hello/here'); + addendumContext.setAddendum('hello/updateded'); }); it('returns early set child addendum', (done) => { - addendumContext.setAddendum('/hello/here'); + addendumContext.setAddendum('hello/here'); const innerChild = new UmbTestChildElement(); child.appendChild(innerChild); const childAddendumContext = new UmbRoutePathAddendumContext(innerChild); - childAddendumContext.setAddendum('/child-specification'); + childAddendumContext.setAddendum('child-specification'); childAddendumContext.observe(childAddendumContext.addendum, (addendum) => { if (addendum) { - expect(addendum).to.equal('/hello/here/child-specification'); + expect(addendum).to.equal('hello/here/child-specification'); done(); } }); }); it('returns late set child addendum', (done) => { - addendumContext.setAddendum('/hello/here'); + addendumContext.setAddendum('hello/here'); const innerChild = new UmbTestChildElement(); child.appendChild(innerChild); const childAddendumContext = new UmbRoutePathAddendumContext(innerChild); childAddendumContext.observe(childAddendumContext.addendum, (addendum) => { if (addendum) { - expect(addendum).to.equal('/hello/here/child-specification'); + expect(addendum).to.equal('hello/here/child-specification'); done(); } }); - childAddendumContext.setAddendum('/child-specification'); + childAddendumContext.setAddendum('child-specification'); }); }); });