Skip to content

Commit

Permalink
Merge ede8c1e into cc88c50
Browse files Browse the repository at this point in the history
  • Loading branch information
loewenheim committed Sep 6, 2023
2 parents cc88c50 + ede8c1e commit 680b862
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Fixes**

- `discover_sourcemaps_location` returns source mapping URLs without query parameters or fragments ([#809](https://github.com/getsentry/symbolic/pull/809))

## 12.3.0

**Features**
Expand Down
13 changes: 12 additions & 1 deletion symbolic-debuginfo/src/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ use debugid::DebugId;
use serde::Deserialize;

/// Parses a sourceMappingURL comment in a file to discover a sourcemap reference.
///
/// Any query string or fragments the URL might contain will be stripped away.
pub fn discover_sourcemaps_location(contents: &str) -> Option<&str> {
for line in contents.lines().rev() {
if line.starts_with("//# sourceMappingURL=") || line.starts_with("//@ sourceMappingURL=") {
return Some(line[21..].trim());
let url = line[21..].trim();

// The URL might contain a query string or fragment. Strip those away before recording the URL.
let without_query = url.split_once('?').map(|x| x.0).unwrap_or(url);
let without_fragment = without_query
.split_once('#')
.map(|x| x.0)
.unwrap_or(without_query);

return Some(without_fragment);
}
}
None
Expand Down

0 comments on commit 680b862

Please sign in to comment.