-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix sslcapath bug #636
Fix sslcapath bug #636
Conversation
Well, I said moving the code, so we can remove the validation in the app.js since we already do the config validation in the config module. No need to validate it twice. |
But what the code does is not validation ,it is reading each file from path just like other ssl option. |
Yes, you are right, I misread it. Thanks for pointing me to this ^^ |
lib/config/index.js
Outdated
var i, len, results | ||
results = [] | ||
for (i = 0, len = config.sslcapath.length; i < len; i++) { | ||
results.push(path.join(appRootPath, config.sslcapath[i])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use path.resolve()
instead of path.join.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we replace other path.join() in index.js into path.resolve()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll do this while refactoring, but right now we touch this part of the code and we should use resolve()
since it doesn't break absolute paths. :)
But it should be changed to resolve()
for the other paths as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just curious is there any good reason to use resolve () instead of join ()? As I know they seems to do the same thing here.
path.join(appRootPath, config.sslcapath[i])
path.resolve(appRootPath, config.sslcapath[i])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While join will simply append the added path, resolve does always return an absolute path to the file. And it can handle absolute path as input, which join doesn't.
so when you put path.join("/opt/hackmd", "/tmp/somefile")
you'll get /opt/hackmd/tmp/somefile
while path.resolve("/opt/hackmd", "/tmp/somefile")
returns /tmp/somefile
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh well.I got it.I just wondered why we'll need put two absolute path as parameter,that really weird since it isn't necessary.
Because if I specified an absolute path in config,the join() can't handle it as expected,right?:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolve
takes absolute paths as well as relatives, but always returns an absolute one.
As mentioned before: path.resolve("/opt/hackmd", "/tmp/somefile")
returns /tmp/somefile
.
But also possible: path.resolve("/opt/hackmd", "config/somefile")
returns /opt/hackmd/config/somefile
.
So resolve
does both, while join
can only handle relative paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a test, but basically approved
Can you please rebase this to the latest master? How to do this?
|
50626c3
to
d5375b0
Compare
wow,thanks for the tips,I don't know I can do this with git. XD |
d5375b0
to
9949795
Compare
#634 Thanks for your suggestion I finally split two pull request.
@SISheogorath