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

url: return backslashes from fileURLToPath on Windows #25349

Closed

Conversation

@zenparsing
Copy link
Contributor

commented Jan 5, 2019

Fixes: #25265

Fixes url.fileURLToPath to return backslash-separated paths instead of forward-separated paths on Windows. This is my first PR to the repo so any and all feedback is welcome.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
@@ -1289,6 +1291,7 @@ function getPathFromURLWin32(url) {
}
}
}
pathname = pathname.replace(forwardSlashRegEx, '\\');

This comment has been minimized.

Copy link
@Trott

Trott Jan 5, 2019

Member

If you think it makes anything more readable here or elsewhere, you can use path.win32.sep and/or path.posix.sep and/or path.sep. (No strong opinion from me on whether or not they should be used here. Just pointing 'em out in case you didn't know about 'em.)

This comment has been minimized.

Copy link
@zenparsing

zenparsing Jan 5, 2019

Author Contributor

I'm not sure I have a strong opinion either.

const url = require('url');

// Input must be string or URL
assert.throws(() => url.fileURLToPath(null));

This comment has been minimized.

Copy link
@Trott

Trott Jan 5, 2019

Member

Linter is complaining that there is no second argument in assert.throws() here and elsewhere. (You can run the JS linter locally with make lint-js or, I believe, vcbuild lint-js. Running make test or, I think, vcbuild test should run the linter as well.) So this instance might be:

assert.throws(() => { url.fileURLToPath(null); }, { code: 'ERR_INVALID_ARG_TYPE' });

We require the second argument because changing the code of the error is considered a breaking change. So we want the test to validate the code property at least.

This comment has been minimized.

Copy link
@zenparsing

zenparsing Jan 5, 2019

Author Contributor

I added the second args. Thanks!

@mscdex

This comment has been minimized.

Copy link
Contributor

commented Jan 5, 2019

FWIW there is already a PR for this change in #25324

@zenparsing zenparsing force-pushed the zenparsing:fix-fileurltopath-windows branch from 7034c68 to a9e54a8 Jan 5, 2019

@zenparsing

This comment has been minimized.

Copy link
Contributor Author

commented Jan 5, 2019

@mscdex Ah, I didn't the other PR. Feel free to use that one if the group think it's higher quality. (Although of course I think this one is better! 😉)

@guybedford
Copy link
Contributor

left a comment

Looks good, and nice to have lots of tests here definitely.

@lpinca
lpinca approved these changes Jan 5, 2019
@bzoz
bzoz approved these changes Jan 7, 2019
Copy link
Contributor

left a comment

This has better tests than my #25324, I'm going to close that other PR.

@bzoz bzoz referenced this pull request Jan 7, 2019
3 of 3 tasks complete
@bzoz

This comment has been minimized.

Copy link
Contributor

commented Jan 7, 2019

@zenparsing zenparsing force-pushed the zenparsing:fix-fileurltopath-windows branch from a9e54a8 to fb44f14 Jan 7, 2019

@@ -63,7 +63,7 @@ if (common.isWindows) {
code: 'ERR_INVALID_ARG_VALUE',
type: TypeError,
message: 'The argument \'path\' must be a string or Uint8Array without ' +
'null bytes. Received \'c:/tmp/\\u0000test\''
'null bytes. Received \'c:\\\\tmp\\\\\\u0000test\''

This comment has been minimized.

Copy link
@zenparsing

zenparsing Jan 7, 2019

Author Contributor

Updated this test after I noticed the error.

The reason for multiple backslashes is that ERR_INVALID_ARG_VALUE calls inspect on the invalid argument value.

@bzoz

This comment has been minimized.

Copy link
Contributor

commented Jan 7, 2019

@zenparsing

This comment has been minimized.

Copy link
Contributor Author

commented Jan 7, 2019

Is the failure

Couldn't find remote ref refs/heads/jenkins-node-test-commit-windows-fanned-fb44f14a3589ef5560470b8cf17145fd2f469d8b-bin-win-vs2017

because I force-pushed my latest update? Or something else?

Thanks for your patience : )

@Trott

This comment has been minimized.

Copy link
Member

commented Jan 7, 2019

because I force-pushed my latest update?

I don't know, but it happens sometimes. Here's a Rebuild: https://ci.nodejs.org/job/node-test-commit-windows-fanned/23794/

@addaleax

This comment has been minimized.

Copy link
Member

commented Jan 8, 2019

@jdalton
jdalton approved these changes Jan 8, 2019
@Trott

This comment has been minimized.

Copy link
Member

commented Jan 8, 2019

https://ci.nodejs.org/job/node-test-pull-request/19965/ passed except for Windows and https://ci.nodejs.org/job/node-test-commit-windows-fanned/23794/ passed for Windows, so I think we're good as far as CI goes. (No commits have been pushed or force-pushed since those runs.)

@danbev

This comment has been minimized.

Copy link
Member

commented Jan 11, 2019

Landed in 7237eaa.

@danbev danbev closed this Jan 11, 2019

danbev added a commit that referenced this pull request Jan 11, 2019
url: return backslashes from fileURLToPath on win
PR-URL: #25349
Fixes: #25265
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
addaleax added a commit that referenced this pull request Jan 14, 2019
url: return backslashes from fileURLToPath on win
PR-URL: #25349
Fixes: #25265
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
@BridgeAR BridgeAR referenced this pull request Jan 16, 2019
BridgeAR added a commit to BridgeAR/node that referenced this pull request Jan 16, 2019
url: return backslashes from fileURLToPath on win
PR-URL: nodejs#25349
Fixes: nodejs#25265
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
@MylesBorins MylesBorins referenced this pull request Jan 24, 2019
BethGriggs added a commit that referenced this pull request Apr 28, 2019
url: return backslashes from fileURLToPath on win
PR-URL: #25349
Fixes: #25265
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
@BethGriggs BethGriggs referenced this pull request May 1, 2019
BethGriggs added a commit that referenced this pull request May 10, 2019
url: return backslashes from fileURLToPath on win
PR-URL: #25349
Fixes: #25265
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
MylesBorins added a commit that referenced this pull request May 16, 2019
url: return backslashes from fileURLToPath on win
PR-URL: #25349
Fixes: #25265
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.