Skip to content

Commit f982435

Browse files
author
Luca Forstner
authored
fix(core): Ignore query and hash in filepaths for release injection (#272)
1 parent 635a60f commit f982435

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/bundler-plugin-core/src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getPackageJson,
1717
parseMajorVersion,
1818
stringToUUID,
19+
stripQueryAndHashFromPath,
1920
} from "./utils";
2021

2122
interface SentryUnpluginFactoryOptions {
@@ -278,11 +279,18 @@ export function createRollupReleaseInjectionHooks(injectionCode: string) {
278279
return null;
279280
}
280281

281-
if (id.match(/\\node_modules\\|\/node_modules\//)) {
282+
// id may contain query and hash which will trip up our file extension logic below
283+
const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
284+
285+
if (idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) {
282286
return null;
283287
}
284288

285-
if (![".js", ".ts", ".jsx", ".tsx", ".mjs"].some((ending) => id.endsWith(ending))) {
289+
if (
290+
![".js", ".ts", ".jsx", ".tsx", ".mjs"].some((ending) =>
291+
idWithoutQueryAndHash.endsWith(ending)
292+
)
293+
) {
286294
return null;
287295
}
288296

packages/bundler-plugin-core/src/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,8 @@ function getBuildInformation() {
271271
nodeVersion: parseMajorVersion(process.version),
272272
};
273273
}
274+
275+
export function stripQueryAndHashFromPath(path: string): string {
276+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
277+
return path.split("?")[0]!.split("#")[0]!;
278+
}

0 commit comments

Comments
 (0)