Skip to content

Commit 62e95b2

Browse files
committed
review suggestions
1 parent b8a73ca commit 62e95b2

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

packages/nuxt/src/common/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ export type SentryNuxtModuleOptions = {
118118
dynamicImportForServerEntry?: boolean;
119119

120120
/**
121-
* By default—unless you configure `dynamicImportForServerEntry: false`—the SDK will try to wrap your application entrypoint
121+
* By default—unless you configure `dynamicImportForServerEntry: false`—the SDK will try to wrap your Nitro server entrypoint
122122
* with a dynamic `import()` to ensure all dependencies can be properly instrumented. Any previous exports from the entrypoint are still exported.
123123
* Most exports of the server entrypoint are serverless functions and those are wrapped by Sentry. Other exports stay as-is.
124124
*
125125
* By default, the SDK will wrap the default export as well as a `handler` or `server` export from the entrypoint.
126-
* If your application has a different main export that is used to run the application, you can overwrite this by providing an array of export names to wrap.
126+
* If your server has a different main export that is used to run the server, you can overwrite this by providing an array of export names to wrap.
127127
* Any wrapped export is expected to be an async function.
128128
*
129129
* @default ['default', 'handler', 'server']

packages/nuxt/src/vite/utils.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function extractFunctionReexportQueryParameters(query: string): { wrap: s
6666
? wrapMatch[1]
6767
.split(',')
6868
.filter(param => param !== '')
69+
// Sanitize, as code could be injected with another rollup plugin
6970
.map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
7071
: [];
7172

@@ -74,6 +75,7 @@ export function extractFunctionReexportQueryParameters(query: string): { wrap: s
7475
? reexportMatch[1]
7576
.split(',')
7677
.filter(param => param !== '' && param !== 'default')
78+
// Sanitize, as code could be injected with another rollup plugin
7779
.map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
7880
: [];
7981

@@ -108,7 +110,7 @@ export function constructWrappedFunctionExportQuery(
108110
consoleSandbox(() =>
109111
// eslint-disable-next-line no-console
110112
console.warn(
111-
"[Sentry] No functions found to wrap. In case your server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.entrypointWrappedFunctions` in your `nuxt.config.ts`.",
113+
"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.entrypointWrappedFunctions` in `nuxt.config.ts`.",
112114
),
113115
);
114116
}
@@ -120,7 +122,7 @@ export function constructWrappedFunctionExportQuery(
120122
? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`
121123
: '';
122124

123-
return [wrapQuery, reexportQuery].filter(Boolean).join('');
125+
return [wrapQuery, reexportQuery].join('');
124126
}
125127

126128
/**

packages/nuxt/test/vite/utils.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('constructWrappedFunctionExportQuery', () => {
152152
const result = constructWrappedFunctionExportQuery(exportedBindings, entrypointWrappedFunctions, debug);
153153
expect(result).toBe('?sentry-query-reexported-functions=handler');
154154
expect(consoleWarnSpy).toHaveBeenCalledWith(
155-
"[Sentry] No functions found to wrap. In case your server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.entrypointWrappedFunctions` in your `nuxt.config.ts`.",
155+
"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to Sentry's build options `sentry.entrypointWrappedFunctions` in `nuxt.config.ts`.",
156156
);
157157

158158
consoleWarnSpy.mockRestore();

0 commit comments

Comments
 (0)