Skip to content

Commit

Permalink
Slightly smarter router
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Dec 15, 2024
1 parent a2bbe04 commit c1ebf14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/output/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ export class DefaultRouter implements Router {

relativeUrl(from: Reflection, to: Reflection): string {
let slashes = 0;
while (!this.hasOwnDocument(from)) {
from = from.parent!;
}
const fromUrl = this.getFullUrl(from);
const toUrl = this.getFullUrl(to);
let equal = true;
Expand Down
2 changes: 2 additions & 0 deletions src/test/output/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ describe("DefaultRouter", () => {

const Foo = query(project, "Foo");
const codeGen = query(project, "Foo.codeGeneration");
const iterator = query(project, "Foo.iterator");
const abc = query(project, "abc");
const Obj = query(project, "Obj");
const ObjArray = query(project, "ObjArray");
Expand All @@ -125,6 +126,7 @@ describe("DefaultRouter", () => {

equal(router.relativeUrl(Obj, ObjArray), "ObjArray.html");
equal(router.relativeUrl(Foo, codeGen), "#codegeneration");
equal(router.relativeUrl(iterator, codeGen), "#codegeneration");
});

it("Can get a URL to an asset relative to the base", () => {
Expand Down

0 comments on commit c1ebf14

Please sign in to comment.