function extractMainDomainFromUrl(url) {
	    try {
	        const domainRe = /(https?:\/\/)?(([\w\d-]+\.)+[\w\d]{2,})/i; // taken example from https://stackoverflow.com/questions/6238351/fastest-way-to-detect-external-urls
	        const data = domainRe.exec(url);
	
	        if (!data || !data[2]) {
	            console.warn("Invalid URL format:", url);
	            return ''; // Return empty if domain extraction fails
	        }
	
	        const domainParts = data[2].split('.');
	        return domainParts.length === 2 ? data[2] : 
	               domainParts.slice(-2).join('.');
	    } catch (error) {
	        console.error("Error extracting main domain:", url, error);
	        return ''; // Safe fallback for unexpected input
	    }
	}
Extracting main domain from the url
@param {*} url