normalize paths with ".." and "." in markdown content

This commit is contained in:
Sebastian Sdorra
2020-05-20 08:39:06 +02:00
parent ffd04eb55b
commit 9f97442d4f
4 changed files with 78 additions and 2 deletions

View File

@@ -100,4 +100,19 @@ describe("test createLocalLink", () => {
const localLink = createLocalLink("/src", "/src/docs/index.md", "/docs/Home.md");
expect(localLink).toBe("/src/docs/Home.md");
});
it("should resolve .. with in path", () => {
const localLink = createLocalLink("/src", "/src/docs/installation/index.md", "../../README.md");
expect(localLink).toBe("/src/README.md");
});
it("should resolve . with in path", () => {
const localLink = createLocalLink("/src", "/src/README.md", "./LICENSE.md");
expect(localLink).toBe("/src/LICENSE.md");
});
it("should handle complex path", () => {
const localLink = createLocalLink("/src", "/src/docs/installation/index.md", "./.././../docs/index.md");
expect(localLink).toBe("/src/docs/index.md");
});
});