File size: 380 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const getHostMatch = ( host: string ) => {
	const urlPattern = /^(https?:\/\/)?([a-zA-Z0-9.-]+)(\/.*)?$/;
	return host.match( urlPattern );
};

export const getHostInput = ( host: string ) => {
	const match = getHostMatch( host );
	return match?.[ 2 ] || '';
};

export const checkHostInput = ( host: string ) => {
	const match = getHostMatch( host );
	return !! match?.[ 2 ];
};