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 file URI handling for Windows platforms #835

Merged
merged 1 commit into from
Mar 12, 2025
Merged

Fix file URI handling for Windows platforms #835

merged 1 commit into from
Mar 12, 2025

Conversation

EvilGenius13
Copy link
Contributor

@EvilGenius13 EvilGenius13 commented Feb 28, 2025

What are you adding in this PR?

Part of Shopify/cli#3497

After a long debugging session and some async work with @aswamy, we found where the issue was coming from.

On windows platforms, filepaths look something like this file:\\\C:\path\to\file.

  • After normalization, it looks like /C:/path/to/file
  • When this glob is provided for asyncGlob on Windows, it gets confused because of the leading /
  • We strip that leading / if it exists before a path

This implementation checks if the OS is windows before changing the way we change the URI to ensure we don't affect unix based systems.

Before you deploy

  • I included a patch bump changeset

@aswamy aswamy marked this pull request as ready for review March 11, 2025 20:37
@aswamy aswamy requested a review from a team as a code owner March 11, 2025 20:37
@aswamy aswamy requested a review from karreiro March 11, 2025 20:37
// start with a drive letter (with few exceptions we can ignore).
// More info: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
//
// If an absoluate path starts with a slash on Windows, we strip it
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a test for this? Is there a reasonable way to accomplish that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a test for this?

Will do!

Is there a reasonable way to accomplish that?

We can't tophat this in a reasonable way because we have to release theme-tools FIRST then update CLI. To verify this works i installed CLI on my windows machine, then updated its source code to contain this change.

@aswamy aswamy force-pushed the fix-windows-uri branch 3 times, most recently from 164cc92 to 16ad83d Compare March 12, 2025 15:34
Co-authored-by: Josh Faigan <josh.faigan@shopify.com>
@aswamy
Copy link
Contributor

aswamy commented Mar 12, 2025

Force push

  • Ended up using a function built into node to convert path to url
  • Still added a test even though we are testing a built-in function so i know it works on Windows as well when it is run in our CI

Built in function:
image

@aswamy aswamy merged commit 5a5b759 into main Mar 12, 2025
7 checks passed
@aswamy aswamy deleted the fix-windows-uri branch March 12, 2025 15:56
@aswamy aswamy mentioned this pull request Mar 12, 2025
3 tasks
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.

3 participants