File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -108,17 +108,21 @@ class Utils {
108108 // Get the search parameters
109109 const params = new URLSearchParams ( parsedUrl . search ) ;
110110
111- if ( ! params || params . size === 0 ) {
111+ if ( ! params || params . size === 0 || ! params . has ( queryParameter ) ) {
112112 return url ;
113113 }
114114
115- // Remove the CMCD parameter
115+ // Remove the queryParameter
116116 params . delete ( queryParameter ) ;
117117
118- // Reconstruct the URL without the CMCD parameter
119- parsedUrl . search = params . toString ( ) ;
118+ // Manually reconstruct the query string without re-encoding
119+ const queryString = Array . from ( params . entries ( ) )
120+ . map ( ( [ key , value ] ) => `${ key } =${ value } ` )
121+ . join ( '&' ) ;
120122
121- return parsedUrl . toString ( ) ;
123+ // Reconstruct the URL
124+ const baseUrl = `${ parsedUrl . origin } ${ parsedUrl . pathname } ` ;
125+ return queryString ? `${ baseUrl } ?${ queryString } ` : baseUrl ;
122126 }
123127
124128 static parseHttpHeaders ( headerStr ) {
Original file line number Diff line number Diff line change @@ -177,6 +177,12 @@ describe('Utils', () => {
177177 expect ( modifiedUrl ) . to . be . equal ( 'http://13.38.43.87:8080/packeng/dash_ll.toml/ateme.mpd' ) ;
178178 } )
179179
180+ it ( 'Should remove query parameter from URL and keep the existing one' , ( ) => {
181+ const url = 'http://13.38.43.87:8080/packeng/dash_ll.toml/ateme.mpd?CMCD=ot%3Dm%2Cpr%3D0.9900013331200346%2Csf%3Dd%2Csid%3D%22f3a875e8-da06-4261-b9fb-124ea694c524%22%2Cst%3Dl&test=123' ;
182+ const modifiedUrl = Utils . removeQueryParameterFromUrl ( url , 'CMCD' ) ;
183+ expect ( modifiedUrl ) . to . be . equal ( 'http://13.38.43.87:8080/packeng/dash_ll.toml/ateme.mpd?test=123' ) ;
184+ } )
185+
180186 it ( 'Should return original URL as query parameter to be removed is not included' , ( ) => {
181187 const url = 'http://13.38.43.87:8080/packeng/dash_ll.toml/ateme.mpd?CMCD=ot%3Dm%2Cpr%3D0.9900013331200346%2Csf%3Dd%2Csid%3D%22f3a875e8-da06-4261-b9fb-124ea694c524%22%2Cst%3Dl' ;
182188 const modifiedUrl = Utils . removeQueryParameterFromUrl ( url , 'C' ) ;
You can’t perform that action at this time.
0 commit comments