Skip to content

Commit 0000a9f

Browse files
committed
fix: strip query strings from sourceMappingURL + fix stale JSDoc
- Strip ?query and #fragment from sourceMappingURL before resolving (Vite/Rollup append ?v=hash which would prevent disk lookup) - Fix ArtifactFile.sourcemapFilename JSDoc: now relative URL, not basename - Fix computeCommonPrefix JSDoc tautology
1 parent 6580967 commit 0000a9f

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/commands/sourcemap/upload.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ const USAGE_HINT = "sentry sourcemap upload <directory>";
6969
/**
7070
* Compute the longest common directory prefix across a list of paths.
7171
*
72-
* Only strips at directory boundaries (slashes), so
73-
* `["a/b/c.js", "a/b/d.js"]` yields `"a/b/"` rather than `"a/b/"`.
74-
* Returns `""` when paths share no common directory prefix.
72+
* Strips at directory boundaries only — `["a/bc.js", "a/bd.js"]`
73+
* yields `"a/"` (not `"a/b"`). Returns `""` when no common dir prefix.
7574
*/
7675
function computeCommonPrefix(paths: string[]): string {
7776
if (paths.length === 0) {

src/lib/api/sourcemaps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ export type ArtifactFile = {
8787
*/
8888
url: string;
8989
/**
90-
* Optional associated sourcemap filename (for minified_source entries).
91-
* Just the basename, e.g., `"bin.js.map"`.
90+
* Optional sourcemap reference for the `Sourcemap` header (minified_source entries).
91+
* Relative URL from the JS file to its map, e.g., `"bin.js.map"` or `"maps/app.js.map"`.
9292
*/
9393
sourcemapFilename?: string;
9494
};

src/lib/sourcemap/inject.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,13 @@ async function findCompanionMap(jsPath: string): Promise<string | undefined> {
195195
return;
196196
}
197197

198+
// Strip query strings and fragments (e.g. "app.js.map?v=abc123")
199+
// that bundlers like Vite/Rollup may append.
200+
const cleanUrl = url.split("?")[0].split("#")[0];
201+
198202
// Resolve relative path against the JS file's directory
199203
const jsDir = dirname(jsPath);
200-
const resolvedMapPath = resolvePath(jsDir, url);
204+
const resolvedMapPath = resolvePath(jsDir, cleanUrl);
201205
if (await fileExists(resolvedMapPath)) {
202206
return resolvedMapPath;
203207
}

0 commit comments

Comments
 (0)