From 4533192b95b4449a1e49926d96cea75f539aa174 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Thu, 1 Aug 2024 17:53:02 +0200 Subject: [PATCH] feat(js): Handle `webpack-internal` prefix (#1506) We have seen webpack paths with a prefix of "webpack-internal:", not just "webpack:". They should be handled analogously to those starting with "webpack:". --- crates/symbolicator-js/src/utils.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/symbolicator-js/src/utils.rs b/crates/symbolicator-js/src/utils.rs index 4e0845b73..f0aa85564 100644 --- a/crates/symbolicator-js/src/utils.rs +++ b/crates/symbolicator-js/src/utils.rs @@ -9,7 +9,7 @@ use crate::api_lookup::ArtifactHeaders; use crate::lookup::SourceMapUrl; static WEBPACK_NAMESPACE_RE: Lazy = - 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 = Lazy::new(|| Regex::new(r"\bnode_modules/").unwrap()); // Names that do not provide any reasonable value, and that can possibly obstruct @@ -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() } @@ -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]