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