@@ -48,21 +48,9 @@ export const legacyBitstreamURLRedirectGuard: CanActivateFn = (
4848 getFirstCompletedRemoteData ( ) ,
4949 map ( ( rd : RemoteData < Bitstream > ) => {
5050 if ( rd . hasSucceeded && ! rd . hasNoContent ) {
51- let nameSpace = ( appConfig . ui . nameSpace || '' ) . replace ( / ^ \/ + | \/ + $ / g, '' ) ;
52- // Neutralize any absolute-like values (http:, https:, //, protocol-relative URLs, or invalid characters)
53- const allowedNamespaceRegex = / ^ [ a - z A - Z 0 - 9 _ - ] + $ / ;
54- // Check for absolute URLs, protocol-relative URLs, or invalid characters
55- if (
56- nameSpace . startsWith ( 'http:' ) ||
57- nameSpace . startsWith ( 'https:' ) ||
58- nameSpace . startsWith ( '//' ) ||
59- nameSpace . match ( / ^ \/ [ ^ \/ ] / ) || // protocol-relative URL: single slash followed by non-slash
60- ! allowedNamespaceRegex . test ( nameSpace )
61- ) {
62- nameSpace = '' ;
63- }
64- const redirectPath = nameSpace ? `/${ nameSpace } /bitstreams/${ rd . payload . uuid } /download` : `/bitstreams/${ rd . payload . uuid } /download` ;
65- const redirectUrl = new URL ( redirectPath , serverHardRedirectService . getCurrentOrigin ( ) ) . href ;
51+ const nameSpace = appConfig . ui . nameSpace ?. replace ( / \/ $ / , '' ) || '' ;
52+ const redirectUrl = new URL ( nameSpace + `/bitstreams/${ rd . payload . uuid } /download` , serverHardRedirectService . getCurrentOrigin ( ) ) . href ;
53+ console . log ( 'Legacy bitstream URL redirecting to:' , redirectUrl ) ;
6654 serverHardRedirectService . redirect ( redirectUrl , 301 ) ;
6755 return false ;
6856 } else {
0 commit comments