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

Fall back to co-location heuristic if sourcemap url appears remote #1871

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brettdh
Copy link
Contributor

@brettdh brettdh commented Dec 21, 2023

Applies a heuristic to guess that a sourcemap URL is a remote URL path (without scheme and domain):

  1. The string starts with /
  2. The string is not a path to an existing local file

Fixes #1870.

@brettdh brettdh force-pushed the 1870-sourcemaps-inject-missing-path branch from a17bef2 to e1909e6 Compare December 21, 2023 15:04
@brettdh brettdh force-pushed the 1870-sourcemaps-inject-missing-path branch from e1909e6 to 50a4008 Compare December 21, 2023 15:15
/// particularly in the case of static asset collection and hosting,
/// but such a path is very unlikely to exist in the local filesystem.
fn is_url_path(url: &str) -> bool {
url.starts_with('/') && !Path::new(url).exists()
Copy link
Member

Choose a reason for hiding this comment

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

As far as I know, path.exists() makes a system call. Can we avoid having validation only filesystem calls, and also achieve the same result of is_url_path purpose? Path::new(url).is_absolute() for example?

@@ -247,6 +247,19 @@ fn is_remote_url(url: &str) -> bool {
};
}

/// Return true iff url appears to be a URL path.
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
/// Return true iff url appears to be a URL path.
/// Return true if url appears to be a URL path.

Copy link

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@brettdh
Copy link
Contributor Author

brettdh commented Jan 30, 2024

This is still on my todo list.

@brettdh
Copy link
Contributor Author

brettdh commented Jan 30, 2024

...but the stalebot did not remove the label. 🤔

@szokeasaurusrex
Copy link
Member

...but the stalebot did not remove the label. 🤔

I removed "Status: Stale" and added "Status: In Progress." Hopefully StaleBot leaves the PR alone going forward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sourcemaps inject should fall back to co-located source maps if exact path can't be found
3 participants