Skip to content

Commit

Permalink
feat(js): Handle webpack-internal prefix (#1506)
Browse files Browse the repository at this point in the history
We have seen webpack paths with a prefix of "webpack-internal:", not just "webpack:". They should be handled analogously to those starting with "webpack:".
  • Loading branch information
loewenheim authored Aug 1, 2024
1 parent 0345bf8 commit 4533192
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/symbolicator-js/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::api_lookup::ArtifactHeaders;
use crate::lookup::SourceMapUrl;

static WEBPACK_NAMESPACE_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"^webpack://[a-zA-Z0-9_\-@\.]+/\./").unwrap());
Lazy::new(|| Regex::new(r"^webpack(-internal)?://[a-zA-Z0-9_\-@\.]+/\./").unwrap());
static NODE_MODULES_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"\bnode_modules/").unwrap());

// Names that do not provide any reasonable value, and that can possibly obstruct
Expand Down Expand Up @@ -104,6 +104,8 @@ pub fn fixup_webpack_filename(filename: &str) -> String {
WEBPACK_NAMESPACE_RE.replace(filename, "./").to_string()
} else if let Some(rest) = filename.strip_prefix("webpack:///") {
rest.to_string()
} else if let Some(rest) = filename.strip_prefix("webpack-internal:///") {
rest.to_string()
} else {
filename.to_string()
}
Expand Down Expand Up @@ -691,6 +693,9 @@ mod tests {
fixup_webpack_filename(filename),
"./app/utils/requestError/createRequestError.tsx"
);

let filename = "webpack-internal:///./src/App.jsx";
assert_eq!(fixup_webpack_filename(filename), "./src/App.jsx");
}

#[test]
Expand Down

0 comments on commit 4533192

Please sign in to comment.