diff --git a/package.json b/package.json index 32ba61a..534204b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fwdekker.com", - "version": "1.8.0", + "version": "1.8.1", "description": "The source code of [my personal website](https://fwdekker.com/).", "author": "Felix W. Dekker", "repository": { diff --git a/src/main/js/FileSystem.ts b/src/main/js/FileSystem.ts index e1c8dac..547d758 100644 --- a/src/main/js/FileSystem.ts +++ b/src/main/js/FileSystem.ts @@ -106,6 +106,9 @@ export class FileSystem { if (target.toString() === "/") return this.root; + console.log("---"); + console.log(target); + console.log(target.parent); const parent = this.get(target.parent); if (!(parent instanceof Directory) || !parent.hasNode(target.fileName)) return undefined; @@ -224,7 +227,7 @@ export class Path { .replaceAll(/(\/+)([^./]+)(\/+)(\.\.)(\/+)/, "/") // Replace `/x/../` with `/` .replaceAll(/\/{2,}/, "/") // Replace `//` with `/` .replaceAll(/^\/\.\.\//, "/") // Replace `/../` at start with `/` - .replace(/(.)\/$/, "$1"); // Remove trailing `/` if not last character + .replace(/(.|\n)\/$/, "$1"); // Remove trailing `/` if not last character const parts = this.path.split("/"); this._parent = parts.slice(0, -1).join("/"); diff --git a/src/test/Path.spec.ts b/src/test/Path.spec.ts index 6b0ff86..36b7a01 100644 --- a/src/test/Path.spec.ts +++ b/src/test/Path.spec.ts @@ -35,6 +35,10 @@ describe("paths", () => { it("interprets the given path as an absolute path", () => { expect(new Path("dir1/file").toString()).to.equal("/dir1/file"); }); + + it("identifies newline characters as characters", () => { + expect(new Path("/dir/\n").toString()).to.equal("/dir/\n"); + }); }); describe("parts", () => {