-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
refactor: only accept string in pathToFsPath #3812
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3812 +/- ##
==========================================
+ Coverage 62.05% 62.10% +0.05%
==========================================
Files 36 36
Lines 1863 1863
Branches 378 378
==========================================
+ Hits 1156 1157 +1
+ Misses 601 600 -1
Partials 106 106
Continue to review full report at Codecov.
|
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.
LGTM! Codecov shamin' us a little for lack of test coverage here though 😂
const isWindows = process.platform === "win32" | ||
const uri = { authority: undefined, path: getFirstString(path), scheme: "file" } | ||
const uri = { authority: undefined, path: getFirstString(path) || "", scheme: "file" } |
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.
just wondering - would this be more readable in expanded form, e.g.
const uri = {
authority: undefined,
path: getFirstString(path) || "",
scheme: "file",
}
I'm not sure if prettier prefers this form though
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.
Definitely is for me! I think Prettier autoformats it though :(
test/unit/node/util.test.ts
Outdated
it("should not throw an error for a string array", () => { | ||
// @ts-expect-error We need to check other types | ||
expect(() => util.pathToFsPath(["/hello/foo", "/hello/bar"]).not.toThrow()) | ||
}) | ||
it("should use the first string in a string array", () => { |
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.
there's no more string array, right? so the description is now outdated
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.
Good catch! I'll update that
ugh I know 😂 I think it's cause I touched some of the routes files, but I didn't write any tests for them so it's unhappy. I'm going to say it's okay for now since at least I'm increasing coverage. |
CodeQL caught a path where we were passing in req.query.path to pathToFsPath, which may not have been a string. So we refactored some things to ensure we only pass it a string which also let us change the parameter type to string instead of string | string[].
aff60ef
to
6e33dcc
Compare
This PR reverts some work done in #3751 to make
pathToFsPath
better.