mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
✨ Allow non standard protocols for ext app URL
This commit is contained in:
@@ -24,7 +24,8 @@
|
|||||||
"isOpeningNewTab": {
|
"isOpeningNewTab": {
|
||||||
"label": "Open in new tab",
|
"label": "Open in new tab",
|
||||||
"description": "Open the app in a new tab instead of the current one."
|
"description": "Open the app in a new tab instead of the current one."
|
||||||
}
|
},
|
||||||
|
"customProtocolWarning": "Using a non-standard protocol. This may require pre-installed applications and can introduce security risks. Ensure that your address is secure and trusted."
|
||||||
},
|
},
|
||||||
"network": {
|
"network": {
|
||||||
"statusChecker": {
|
"statusChecker": {
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ import { EditAppModalTab } from './Tabs/type';
|
|||||||
const appUrlRegex =
|
const appUrlRegex =
|
||||||
'(https?://(?:www.|(?!www))\\[?[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\]?.[^\\s]{2,}|www.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9].[^\\s]{2,}|https?://(?:www.|(?!www))\\[?[a-zA-Z0-9]+\\]?.[^\\s]{2,}|www.[a-zA-Z0-9]+.[^\\s]{2,})';
|
'(https?://(?:www.|(?!www))\\[?[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\]?.[^\\s]{2,}|www.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9].[^\\s]{2,}|https?://(?:www.|(?!www))\\[?[a-zA-Z0-9]+\\]?.[^\\s]{2,}|www.[a-zA-Z0-9]+.[^\\s]{2,})';
|
||||||
|
|
||||||
|
const appUrlWithAnyProtocolRegex =
|
||||||
|
'([A-z]+://(?:www.|(?!www))\\[?[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\]?.[^\\s]{2,}|www.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9].[^\\s]{2,}|[A-z]+://(?:www.|(?!www))\\[?[a-zA-Z0-9]+\\]?.[^\\s]{2,}|www.[a-zA-Z0-9]+.[^\\s]{2,})';
|
||||||
|
|
||||||
export const EditAppModal = ({
|
export const EditAppModal = ({
|
||||||
context,
|
context,
|
||||||
id,
|
id,
|
||||||
@@ -71,8 +74,8 @@ export const EditAppModal = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!url.match(appUrlRegex)) {
|
if (!url.match(appUrlWithAnyProtocolRegex)) {
|
||||||
return 'Uri override is not a valid uri';
|
return 'External URI is not a valid uri';
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Tabs, TextInput } from '@mantine/core';
|
import { Tabs, Text, TextInput } from '@mantine/core';
|
||||||
import { UseFormReturnType } from '@mantine/form';
|
import { UseFormReturnType } from '@mantine/form';
|
||||||
import { IconClick, IconCursorText, IconLink } from '@tabler/icons-react';
|
import { IconClick, IconCursorText, IconLink } from '@tabler/icons-react';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
@@ -22,6 +22,7 @@ export const GeneralTab = ({ form, openTab }: GeneralTabProps) => {
|
|||||||
placeholder="My example app"
|
placeholder="My example app"
|
||||||
variant="default"
|
variant="default"
|
||||||
withAsterisk
|
withAsterisk
|
||||||
|
mb="md"
|
||||||
{...form.getInputProps('name')}
|
{...form.getInputProps('name')}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
@@ -31,10 +32,8 @@ export const GeneralTab = ({ form, openTab }: GeneralTabProps) => {
|
|||||||
placeholder="https://google.com"
|
placeholder="https://google.com"
|
||||||
variant="default"
|
variant="default"
|
||||||
withAsterisk
|
withAsterisk
|
||||||
|
mb="md"
|
||||||
{...form.getInputProps('url')}
|
{...form.getInputProps('url')}
|
||||||
onChange={(e) => {
|
|
||||||
form.setFieldValue('url', e.target.value);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
icon={<IconClick size={16} />}
|
icon={<IconClick size={16} />}
|
||||||
@@ -44,6 +43,13 @@ export const GeneralTab = ({ form, openTab }: GeneralTabProps) => {
|
|||||||
variant="default"
|
variant="default"
|
||||||
{...form.getInputProps('behaviour.externalUrl')}
|
{...form.getInputProps('behaviour.externalUrl')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{!form.values.behaviour.externalUrl.startsWith('https://') &&
|
||||||
|
!form.values.behaviour.externalUrl.startsWith('http://') && (
|
||||||
|
<Text color="red" mt="sm" size="sm">
|
||||||
|
{t('behaviour.customProtocolWarning')}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Tabs.Panel>
|
</Tabs.Panel>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user