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

Use url.pathToFileURL to correctly resolve functions paths on windows #3412

Merged
merged 4 commits into from
Apr 18, 2024

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Apr 17, 2024

Fixes #3405

Use url.pathToFileURL to correctly resolve paths on windows

@Janpot Janpot added the bug 🐛 Something doesn't work label Apr 17, 2024
@Janpot Janpot changed the title Update functionsRuntime.ts Use url.pathToFileURL to correctly resolve functions paths on windows Apr 17, 2024
@Janpot Janpot marked this pull request as ready for review April 17, 2024 18:04
@Janpot Janpot requested a review from a team April 17, 2024 18:04
import * as fs from 'fs/promises';
import { TOOLPAD_DATA_PROVIDER_MARKER, ToolpadDataProvider } from '@toolpad/studio-runtime/server';
import * as z from 'zod';
import { fromZodError } from 'zod-validation-error';
import * as crypto from 'crypto';

async function loadExports(filePath: string): Promise<Map<string, unknown>> {
const fullPath = path.resolve(filePath);
const content = await fs.readFile(fullPath, 'utf-8');
const importFileUrl = url.pathToFileURL(path.resolve(filePath));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const importFileUrl = url.pathToFileURL(path.resolve(filePath));
// Correct cross-platform resolution of the import URL
// See: https://nodejs.org/api/url.html#urlpathtofileurlpath
const importFileUrl = url.pathToFileURL(path.resolve(filePath));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case vscode doesn't suffice? 😄

Screenshot 2024-04-18 at 09 27 30

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 I thought it deserves special placement because of the bug. Perhaps we can link to the issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I've added a comment

@Janpot Janpot merged commit 02b0abf into mui:master Apr 18, 2024
12 checks passed
@Janpot Janpot deleted the fix-windows branch April 18, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
2 participants