correct path generation

This commit is contained in:
Niels Lyngsø
2025-01-09 14:29:49 +01:00
parent 0eef5e5801
commit d879919d75
2 changed files with 14 additions and 13 deletions

View File

@@ -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);
}
}

View File

@@ -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');
});
});
});