Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Why normalize drive letter to lower case? #7880

Closed
fouber opened this issue Jul 2, 2014 · 8 comments
Closed

Why normalize drive letter to lower case? #7880

fouber opened this issue Jul 2, 2014 · 8 comments

Comments

@fouber
Copy link

fouber commented Jul 2, 2014

from v0.11.x,path.normalize will normalize drive letter to lower case:
https://github.com/joyent/node/blob/v0.11.0-release/lib/path.js#L179-L182

why?

@hefangshi
Copy link

When you use __dirname to get path, you will get a upper case drive letter, so i don't think the lower case behavior is necessary.

@JacksonTian
Copy link

Maybe, because the module cache issue under Windows.

@indutny
Copy link
Member

indutny commented Jul 2, 2014

As far as I remember, because of the cache, as @JacksonTian said.

@indutny indutny closed this as completed Jul 2, 2014
@fouber
Copy link
Author

fouber commented Jul 2, 2014

@JacksonTian

what's the "module cache issue"? could u give some more information?

@Mithgol
Copy link

Mithgol commented Jul 2, 2014

@fouber If you require() one module twice, you get two references to the same module (the reference is taken from Node.js module cache) instead of producing a clone (i.e. exact and separate copy) of the module.

It works where the paths to the two modules are equal, though there are problems with that on Windows.

When paths are somehow not equal (see #6829 for example), you get a clone. It means that you loose some time when the module is parsed by the engine once again, and then a change in internal state of one of these modules does not affect the other, which is inconvenient.

@fouber
Copy link
Author

fouber commented Jul 2, 2014

@Mithgol

thx very much!

@hefangshi
Copy link

the module cache issue seems handled with #6774 , it handled the full filename not driver letter. so there is no need to use a lower case drive letter, and I still don't get why use the lower case driver letter which conflict with __dirname

the driver letter change come from a05f973

@jonschlinkert
Copy link

jonschlinkert commented Jul 26, 2014

there is no need to use a lower case drive letter

This broke every unit test I have that compares a file path from an API method with, say, __dirname + '/fixtures/foo is now broken. Additionally, since using __dirname will still return an uppercase drive letter, both paths (fixture and actual) need case-normalization for the tests to pass.

Please consider reopening this as a bug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants