@@ -43,14 +43,17 @@ export default function useNetworkInterceptor({
4343 setNetworkRequests ( initRequests ) ;
4444 } ;
4545
46+ const isMatchedDomain = ( url : string ) => {
47+ if ( ! includeDomains ?. length ) return true ;
48+
49+ return includeDomains . some ( domain => url . includes ( domain ) ) ;
50+ } ;
51+
4652 const enableHttpInterceptions = useCallback ( ( ) => {
4753 const openCallback : HttpHandlers [ 'open' ] = ( id , type , method , url ) => {
4854 if ( ! id ) return ;
4955
50- const isNotMatchedDomain =
51- ! ! joinedIncludeDomains . length && ! includeDomains ?. some ( domain => url . includes ( domain ) ) ;
52-
53- if ( isNotMatchedDomain ) return ;
56+ if ( ! isMatchedDomain ( url ) ) return ;
5457
5558 setNetworkRequests ( ( draft : NetworkRequests < HttpRequest > ) => {
5659 draft . set ( id , { type, method, url } ) ;
@@ -162,6 +165,8 @@ export default function useNetworkInterceptor({
162165 ) => {
163166 if ( typeof socketId !== 'number' ) return ;
164167
168+ if ( ! isMatchedDomain ( url ) ) return ;
169+
165170 setNetworkRequests ( ( draft : NetworkRequests < WebSocketRequest > ) => {
166171 draft . set ( `${ socketId } ` , {
167172 startTime,
@@ -245,7 +250,8 @@ export default function useNetworkInterceptor({
245250 . set ( 'onError' , onErrorCallback )
246251 . set ( 'onClose' , onCloseCallback )
247252 . enableInterception ( ) ;
248- } , [ setNetworkRequests ] ) ;
253+ // eslint-disable-next-line react-hooks/exhaustive-deps
254+ } , [ joinedIncludeDomains , setNetworkRequests ] ) ;
249255
250256 const enableInterception = useCallback ( ( ) => {
251257 if ( isEnabled ( ) ) return ;
0 commit comments