This commit is contained in:
root
2026-01-25 21:52:50 +05:00
parent d5a7748a28
commit fc28cca365
@@ -551,7 +551,7 @@
<td class="competitive-env-td">
<a
v-if="competitor.website"
:href="competitor.website"
:href="getFullUrl(competitor.website)"
target="_blank"
rel="noopener noreferrer"
class="text-primary-500 hover:text-primary-700 dark:hover:text-primary-400 flex align-items-center"
@@ -3756,17 +3756,40 @@ const onChartClick = (event, elements) => {
const handleRowClick = (competitor) => {
if (competitor.website) {
window.open(competitor.website, '_blank', 'noopener,noreferrer');
let url = competitor.website.trim();
// If URL doesn't start with http:// or https://, add https://
if (!url.match(/^https?:\/\//i)) {
url = 'https://' + url;
}
window.open(url, '_blank', 'noopener,noreferrer');
}
};
const getFullUrl = (url) => {
if (!url) return '';
const trimmed = url.trim();
// If URL doesn't start with http:// or https://, add https://
if (!trimmed.match(/^https?:\/\//i)) {
return 'https://' + trimmed;
}
return trimmed;
};
const formatWebsite = (url) => {
if (!url) return '';
const trimmed = url.trim();
try {
const urlObj = new URL(url);
return urlObj.hostname.replace('www.', '');
// If it's already a full URL, parse it
if (trimmed.match(/^https?:\/\//i)) {
const urlObj = new URL(trimmed);
return urlObj.hostname.replace('www.', '');
}
// Otherwise, just return the domain part (before first /)
const domain = trimmed.split('/')[0];
return domain.replace('www.', '');
} catch {
return url;
// If parsing fails, return as is (might be just domain name)
return trimmed.split('/')[0].replace('www.', '');
}
};