File size: 694 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import isA8CForAgencies from 'calypso/lib/a8c-for-agencies/is-a8c-for-agencies';

export function isValidURL( url: string ) {
	if ( 'canParse' in URL ) {
		return URL.canParse( url );
	}
	return /^(https?:\/\/)?((?!false\.)([a-z0-9-]+\.)+)[a-z]{2,}(:[0-9]{1,5})?(\/[^\s]*)?$/i.test(
		url
	);
}

// Returns props for the support link based on the current environment
export function getSupportLinkProps() {
	return {
		showIcon: false,
		supportContext: isA8CForAgencies() ? 'a4a-site-performance' : 'site-performance',
		showSupportModal: ! isA8CForAgencies(),
		supportLink:
			isA8CForAgencies() &&
			'https://agencieshelp.automattic.com/knowledge-base/check-your-sites-performance',
	};
}