Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Path normalization is broken for paths like C:\ (makes Atom misbehave) #109

@magv

Description

@magv

Hi. I've been investigating a broken behavior in Atom, and traced it down to this library.

In short, if you create a Directory for C:\ like so:

var pw = require("pathwatcher");
var d = new pw.Directory("C:\\");
console.log(d.path);
// "C:" is printed

... the path is normalized to C: (see directory.cofee; introduced in 0630c38). This normalization is incorrect; path should remain at C:\.

The problem is that libaries like node's path recognize C:\ as an absolute directory (path.isAbsolute("C:\\") is true), but not C: (path.isAbsolute("C:") is false). This, among other things, leads to various problems when you pass C:, where C:\ should have been.

The impact of the problem is this: when you add a project path to Atom and select a drive, like C: (or, Z: in my case; it's a network mapped drive), atom.pickFolder returns path in the correct form C:\. After you exit Atom, ~/.atom/storage says that initialPath is actually C:. This is due to normalization that pathwatcher performs (note that path.normalize and fs-plus.absolute all preserve the final slash). When you reopen Atom, it will try to create a new file called C (located in Atom's installation path) in addition to opening directories. This behavior is bogus, and does not happen if initialPath is set to C:\.

I think pathwatcher should change it's normalization somehow. Maybe abolish it altogether. Maybe always add a trailing slash instead of removing it. Whatever you think is best. I look forward to not having my Atom broken.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions