Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with generated urls when running node via powershell #130

Closed
webuniverseio opened this issue Apr 7, 2015 · 4 comments
Closed

Issue with generated urls when running node via powershell #130

webuniverseio opened this issue Apr 7, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@webuniverseio
Copy link
Contributor

When I get api/specs/raw json data, it contains local file paths instead or urls. I digged through the code a bit and found out why it is happening. In file-tree/index.js there is a line:

urlForJson = _specPath.replace(normalizedPathToApp, '');

The issue is happening when _specPath is different from normalizedPathToApp, for example when drive letter has different case:
_specPath = c:/dev/node_projects/sourcejs/docs/auth/readme.md
normalizedPathToApp = C:/dev/node_projects/sourcejs

It could happen because var normalizedPathToApp = global.pathToApp.replace(/\\/g, '/'); and global.pathToApp = __dirname;. Funny enough but when node started via powershell, __dirname will return path with drive letter in uppercase, while when started with cmd, node will return path with lowercase... :S

So I guess there should be conversion to lowercase?

@robhrt7
Copy link
Member

robhrt7 commented Apr 7, 2015

Hi, thanks for your report.

It's always an issue working with file paths in cross-platform environment, first the back-slashes and now different letter case. It's really strange that node fs returns different paths in this situation.

Anyway, the only solution will be normalizing the case as well, applying toLowerCase() in paths at file-tree/index.js.

I suggest you hotfixing it locally for now, and I will investigate this issue with more focus, applying the fix in one of the 0.5.x versions.

Could you please also provide the link to Windows Powershell download, and define it's version?

@robhrt7 robhrt7 self-assigned this Apr 7, 2015
@robhrt7 robhrt7 added this to the 0.5.x milestone Apr 7, 2015
@robhrt7 robhrt7 added the bug label Apr 7, 2015
@webuniverseio
Copy link
Contributor Author

Hi Robert, powershell was preinstalled on my windows 8.1. Here is a PS version:

PS C:\Users\Sergey> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

I verified on node 0.12.0, windows 8.1 with PS 4.0 and on node 0.11.13, windows server 2008 with PS 2.0 - it works the same way, drive letter is in uppercase.

@robhrt7 robhrt7 modified the milestones: 0.5.3, 0.5.x Apr 17, 2015
@robhrt7
Copy link
Member

robhrt7 commented Apr 25, 2015

I digged deeper into the problem and noticed that starting from Node.js 0.11.x path.join is changing the case of the disk name.

__dirname // -> C:\User\path
path.join(__dirname, 'some') // -> c:\User\path\some

Following my tests, it's true both for cmd and powershell on windows 8.1. Here's also a similar issue in Node.js project - nodejs/node-v0.x-archive#7031.

Since Windows is case-insensetive, then I believe lowering the disk name by default will be a stable fix.

@robhrt7 robhrt7 closed this as completed Apr 25, 2015
@webuniverseio
Copy link
Contributor Author

Awesome, thanks for double checking

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

No branches or pull requests

2 participants