@@ -14,7 +14,7 @@ import type { Handle } from '@sveltejs/kit';
1414import { redirect } from '@sveltejs/kit' ;
1515import { vi } from 'vitest' ;
1616
17- import { FETCH_PROXY_SCRIPT , addSentryCodeToPage , sentryHandle } from '../../src/server/handle' ;
17+ import { FETCH_PROXY_SCRIPT , addSentryCodeToPage , isFetchProxyRequired , sentryHandle } from '../../src/server/handle' ;
1818import { getDefaultNodeClientOptions } from '../utils' ;
1919
2020const mockCaptureException = vi . spyOn ( SentryNode , 'captureException' ) . mockImplementation ( ( ) => 'xx' ) ;
@@ -462,3 +462,20 @@ describe('addSentryCodeToPage', () => {
462462 expect ( transformed ) . not . toContain ( `<script >${ FETCH_PROXY_SCRIPT } </script>` ) ;
463463 } ) ;
464464} ) ;
465+
466+ describe ( 'isFetchProxyRequired' , ( ) => {
467+ it . each ( [ '2.16.0' , '2.16.1' , '2.17.0' , '3.0.0' , '3.0.0-alpha.0' ] ) (
468+ 'returns false if the version is greater than or equal to 2.16.0 (%s)' ,
469+ version => {
470+ expect ( isFetchProxyRequired ( version ) ) . toBe ( false ) ;
471+ } ,
472+ ) ;
473+
474+ it . each ( [ '2.15.0' , '2.15.1' , '1.30.0' , '1.0.0' ] ) ( 'returns true if the version is lower than 2.16.0 (%s)' , version => {
475+ expect ( isFetchProxyRequired ( version ) ) . toBe ( true ) ;
476+ } ) ;
477+
478+ it . each ( [ 'invalid' , 'a.b.c' ] ) ( 'returns true for an invalid version (%s)' , version => {
479+ expect ( isFetchProxyRequired ( version ) ) . toBe ( true ) ;
480+ } ) ;
481+ } ) ;
0 commit comments