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

Fix path on Windows #4223

Merged
merged 2 commits into from
Mar 29, 2022
Merged

Fix path on Windows #4223

merged 2 commits into from
Mar 29, 2022

Conversation

compulim
Copy link
Contributor

@compulim compulim commented Mar 28, 2022

Fixes #4102.

Changelog Entry

Description

cldr-data-downloader we forked and ported to ESM earlier in PR #3998 wasn't working on Windows.

Under Node.js, there are two file path scheme:

  • CJS use OS native file path (e.g. C:\Users\...);
  • ESM requires URL-based file path (e.g. file:///C:/Users/...).

We mixed them up in the port. It was broken-but-working on Linux because we are using the path as a relative. However, under Windows, it exposed the issue.

Design

We prefer OS native file path when passing the path externally, say, from cldr-data package to cldr-data-downloader package.

Internally, it depends. Because mkdir and other fs functions prefer OS native file path.

There is an utility function named isUrl. It is supposed to check if the path is a URL or OS native file path. However, it consider C:\Users\... is a URL, instead of OS native file path. We fixed it.

In the future, we should consider adding a PR validation pipeline that runs on Windows, in addition to Linux.

Specific Changes

  • Updated index.js and util.js in cldr-data-downloader to handle file path correctly
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@compulim compulim marked this pull request as ready for review March 29, 2022 13:45
@compulim compulim merged commit da26b55 into microsoft:main Mar 29, 2022
@compulim compulim deleted the fix-4102 branch March 29, 2022 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Whops The URL must be of scheme file" error while trying to build the code on windows
2 participants