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

feat(inject): Handle relative and absoule sourcemap URLs #1530

Merged
merged 3 commits into from
Mar 24, 2023

Conversation

loewenheim
Copy link
Contributor

This adds a function that should handle all forms of sourcemap URL correctly, not just the most basic ones. The logic that preserves initial ./ segments is pretty cursed though.

@loewenheim loewenheim self-assigned this Mar 16, 2023
@loewenheim loewenheim linked an issue Mar 16, 2023 that may be closed by this pull request
@kamilogorek
Copy link
Contributor

We already have this resolution util in https://github.com/getsentry/sentry-cli/blob/master/src/commands/sourcemaps/explain.rs#L335 (including tests at the bottom)

@loewenheim
Copy link
Contributor Author

Does that handle paths containing .. though?

@kamilogorek
Copy link
Contributor

kamilogorek commented Mar 17, 2023

Yup

fn main() {
    let base = dbg!(url::Url::parse("http://example.com/a/b/c/bundle.js").unwrap());
    let map = dbg!(base.join("../../bundle.js.map").unwrap().to_string());
    assert_eq!(map, "http://example.com/a/bundle.js.map");
}

@loewenheim
Copy link
Contributor Author

Tbh I don't see how this can work for our test cases. Our source "urls" aren't actual URLs, they're things like ./server/chunks/1.js.

@kamilogorek
Copy link
Contributor

Ugh right, I forgot it's not the abs_path we're resolving to in this case, as we're collecting files locally 😔

@loewenheim loewenheim merged commit 1279750 into master Mar 24, 2023
@loewenheim loewenheim deleted the feat/inject-sourcemap-url branch March 24, 2023 15:59
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.

sourcemaps inject: Correctly handle all sourcemap URLs
2 participants