[close #115] Support Windows filesystem #118
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Windows uses a filesystem that starts with a drive letter than a colon and a slash. This is different from *nix systems that only start with a slash. Previous releases 3.3.{1,2,3} didn't take this into consideration.
Targeted at 4.x
To support windows we have to make sure we can correctly expand both kinds of paths. Previously we were checking if a path started with a slash to indicate it was already an absolute path and that we don't need to prepend the root to it. Now we also check for a drive letter + colon + slash. I added tests for windows style paths and this works for compressing them. The downside is that someone could create a folder in their app root called
C:
and this code would incorrectly think that the path was absolute and not expand it. I would assume this would happen in an EXTREME minority of cases, but when it does happen it will be very frustrating to find and fix. We could explicitly check for when you're on a windows machine usingGem.win_platform?
but I don't know how accurate this code is, and it would make running tests on *nix platforms difficult.In addition to expanding uris, we also have to support compressing them. The root object we get from windows will not contain a beginning slash, it will be something like
C:/Path/to/root
. Unfortunately the path code we've written will produce paths with beginning slashes. If the path starts with a slash we must make sure the root starts with a slash. If we don't then when we try to get a compressed path fromfile:///C:/Projects/Rails/app/assets/javascripts/application.js
which has a path of/C:/Projects/Rails/app/assets/javascripts/application.js
it will not correctly compare with it's root which isC:/Projects/Rails/
. I'm pretty sure this doesn't impact *nix systems as their root will always begin with a slash.Added tests for the new behavior.