Url validation
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user