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') {
openWeatherModal();
} else if (providerLabel.startsWith('Launch')) {
open(
`https://${applicationData.find((app: Application) => app.baseUrl.substring(1).toLowerCase() === item.target.value.substr(1)).url}`,
'_self',
);
const url = applicationData.find(
(app: Application) =>
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)) {
if (/^(https?:\/\/).*/i.test(item.target.value))
window.location = item.target.value;