Url validation

This commit is contained in:
2025-04-07 23:42:27 -05:00
parent b7c9fa2066
commit 0133731396

View File

@@ -97,10 +97,13 @@ export default function Search({
} else if (providerLabel === 'Show weather') { } else if (providerLabel === 'Show weather') {
openWeatherModal(); openWeatherModal();
} else if (providerLabel.startsWith('Launch')) { } else if (providerLabel.startsWith('Launch')) {
open( const url = applicationData.find(
`https://${applicationData.find((app: Application) => app.baseUrl.substring(1).toLowerCase() === item.target.value.substr(1)).url}`, (app: Application) =>
'_self', app.baseUrl.substring(1).toLowerCase() === item.target.value.substr(1),
); ).url;
const validUrl =
url.startsWith('http://') || url.startsWith('https://') ? url : `http://${url}`;
open(validUrl, '_self');
} else if (urlPattern.test(item.target.value)) { } else if (urlPattern.test(item.target.value)) {
if (/^(https?:\/\/).*/i.test(item.target.value)) if (/^(https?:\/\/).*/i.test(item.target.value))
window.location = item.target.value; window.location = item.target.value;