Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Correctly normalize UNC paths #6041

Merged
merged 3 commits into from
Nov 19, 2013
Merged

Correctly normalize UNC paths #6041

merged 3 commits into from
Nov 19, 2013

Conversation

iwehrman
Copy link
Contributor

Add support for normalization of UNC paths in the filesystem. _normalizePath is now a method of the FileSystem class. Its behavior w.r.t. UNC paths is controlled by a new FileSystemImpl flag, normalizeUNCPaths. If set, paths like ///server//foo/bar are normalized to //server/foo/bar/ instead of /server/foo/bar/. AppshellFileSystemImpl.normalizeUNCPaths is set at runtime for Windows only.

Addresses #6028 and #6029.

CC @gruehle @peterflynn

…y the FileSystemImpl.normalizeUNCPaths flag

if (!FileSystem.isAbsolutePath(path)) {
throw new Error("Paths must be absolute: '" + path + "'"); // expect only absolute paths
}


var normalizeUNCPaths = this._impl && this._impl.normalizeUNCPaths,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a bug if we get called while this._impl is undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is at least one group of instances of this that didn't seem crazy to me: In JSUtils-tests.js, there are calls to FileSystem.getFileForPath within the module scope. I decided not to call this a bug, but I guess I could be convinced otherwise.

@iwehrman
Copy link
Contributor Author

Pushed one fix for the RE naming and JSDoc. I'm happy to throw an exception in case _normalizePath is called before init(). I didn't do that initially because it seemed potentially disruptive and probably not useful. (It's also kind of hard to grep through extensions to see if this is common.)

Less excited about adding a Windows flag to trim out the single colon-in-paths case of normalization, but I don't really have strong feelings either way. Just let me know what you think is best and I'll push the keys. I'm also happy if you just merge because I think both decisions are perfectly fine :)

@iwehrman
Copy link
Contributor Author

I now think that, yes, we should throw if you try to normalize a path before init. Will fix tomorrow.

@iwehrman
Copy link
Contributor Author

The fixing is taking a little longer than I expected. I'm in require.js hell.

@peterflynn
Copy link
Member

@iwehrman Given that we want to sneak this in as a last-minute fix for EC, maybe we should just do the simple fix for now and clean up the "normalization before init" stuff in a subsequent (master-only) PR... It looks good to merge to me.

…ize the singleton instance at module load
@iwehrman
Copy link
Contributor Author

Ready for re-review.

@iwehrman
Copy link
Contributor Author

Impl documentation updated accordingly.

@gruehle
Copy link
Member

gruehle commented Nov 19, 2013

Looks good. Merging.

gruehle added a commit that referenced this pull request Nov 19, 2013
@gruehle gruehle merged commit 9a1fe2e into master Nov 19, 2013
@gruehle gruehle deleted the iwehrman/normalize-UNC-paths branch November 19, 2013 20:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants