File size: 674 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import config from '@automattic/calypso-config';

// Page library adds the query string at the end of the initial path on the hash.
// We don't want that, so we clean the query and show the correct path when the app starts
export default ( path = '' ) => {
	const index = path.indexOf( '?' );
	path = index >= 0 ? path.substring( 0, index ) : path;

	// Fix the blaze path prefix if its not correct
	if ( path && ! path.startsWith( config( 'advertising_dashboard_path_prefix' ) ) ) {
		const segments = path.split( '/' );
		if ( segments.length > 1 ) {
			path = path.replace( `/${ segments[ 1 ] }`, config( 'advertising_dashboard_path_prefix' ) );
		}
	}

	return path;
};