File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,15 @@ export function init(options: NextjsOptions): void {
79
79
const activeDomain = domain . active ;
80
80
domain . active = null ;
81
81
82
+ if ( typeof options . tunnel !== 'undefined' ) {
83
+ try {
84
+ new URL ( options . tunnel ) ;
85
+ } catch ( error ) {
86
+ __DEBUG_BUILD__ &&
87
+ logger . error ( 'The tunnel option is not a valid URL. It must be a full URL including the protocol.' ) ;
88
+ throw new Error ( 'The tunnel option is not a valid URL. It must be a full URL including the protocol.' ) ;
89
+ }
90
+ }
82
91
nodeInit ( options ) ;
83
92
84
93
const filterTransactions : EventProcessor = event => {
Original file line number Diff line number Diff line change @@ -139,6 +139,24 @@ describe('Server init()', () => {
139
139
} ) ;
140
140
} ) ;
141
141
142
+ it ( 'should not fail on valid tunnel option' , ( ) => {
143
+ expect ( ( ) =>
144
+ init ( {
145
+ dsn : 'https://dogsarebadatkeepingsecrets@squirrelchasers.ingest.sentry.io/12312012' ,
146
+ tunnel : 'https://example.com/api' ,
147
+ } ) ,
148
+ ) . not . toThrowError ( ) ;
149
+ } ) ;
150
+
151
+ it ( 'should fail on invalid tunnel option' , ( ) => {
152
+ expect ( ( ) =>
153
+ init ( {
154
+ dsn : 'https://dogsarebadatkeepingsecrets@squirrelchasers.ingest.sentry.io/12312012' ,
155
+ tunnel : '/invalid' ,
156
+ } ) ,
157
+ ) . toThrowError ( 'The tunnel option is not a valid URL. It must be a full URL including the protocol.' ) ;
158
+ } ) ;
159
+
142
160
describe ( 'integrations' , ( ) => {
143
161
// Options passed by `@sentry/nextjs`'s `init` to `@sentry/node`'s `init` after modifying them
144
162
type ModifiedInitOptions = { integrations : Integration [ ] } ;
You can’t perform that action at this time.
0 commit comments