-
Notifications
You must be signed in to change notification settings - Fork 121
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 within on Windows #1804
fix within on Windows #1804
Conversation
191a578
to
28ac2c1
Compare
export const toOsPath = sep === op.sep ? (path: string) => path : (path: string) => path.split(sep).join(op.sep); | ||
export const fromOsPath = sep === op.sep ? (path: string) => path : (path: string) => path.split(op.sep).join(sep); |
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.
This doesn’t change functionality; just trivial optimization.
28ac2c1
to
ea24610
Compare
@@ -86,6 +87,7 @@ export function parseRelativeUrl(url: string): {pathname: string; search: string | |||
} | |||
|
|||
export function within(root: string, path: string): boolean { | |||
const {relative, normalize, resolve, isAbsolute} = op; | |||
path = relative(normalize(resolve(root)), normalize(resolve(path))); |
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.
The main issue was that process.cwd()
returns a “namespaced” absolute path starting with e.g. D:\
, whereas resolve(path)
returns a non-namespaced absolute path. See these logs for reference:
https://github.com/observablehq/framework/actions/runs/11717337869/job/32636834499
Ref. #1792