Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Fix default protocol validation list

Gabe Kangas4364fee901c2
diff --git a/web/pages/admin/actions.tsx b/web/pages/admin/actions.tsx
index c337feda2e..f430610401 100644
--- a/web/pages/admin/actions.tsx
+++ b/web/pages/admin/actions.tsx
@@ -69,16 +69,7 @@ const ActionModal = (props: Props) => {
}
function canSave(): Boolean {
- try {
- const validationObject = new URL(actionUrl);
- if (validationObject.protocol !== 'https:') {
- return false;
- }
- } catch {
- return false;
- }
-
- return isValidUrl(actionUrl) && actionTitle !== '';
+ return isValidUrl(actionUrl, ['https:']) && actionTitle !== '';
}
const okButtonProps = {
diff --git a/web/utils/urls.ts b/web/utils/urls.ts
index fbee5a2647..4a64ec9710 100644
--- a/web/utils/urls.ts
+++ b/web/utils/urls.ts
@@ -7,10 +7,10 @@ export const DEFAULT_TEXTFIELD_URL_PATTERN = 'https?://.*';
* @param {string[]} validProtocols - An array of valid protocols. Defaults to web.
* @returns {boolean} - True if the URI is valid, false otherwise.
*/
-export function isValidUrl(url: string, validProtocols: string[] = ['http', 'https']): boolean {
- console.log(url, validProtocols);
+export function isValidUrl(url: string, validProtocols: string[] = ['http:', 'https:']): boolean {
try {
const validationObject = new URL(url);
+
if (
validationObject.protocol === '' ||
validationObject.hostname === '' ||