Fix #53
This commit is contained in:
parent
3d91346cc5
commit
a9309bcd4e
|
@ -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": {
|
||||
|
|
|
@ -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("/");
|
||||
|
|
|
@ -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", () => {
|
||||
|
|
Loading…
Reference in New Issue