Skip to content

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

Don't allow people to set their instance name to an empty string (or only whitespace) (#240)

Meisam7a1f9dcd9a0d
diff --git a/web/components/config/form-textfield-with-submit.tsx b/web/components/config/form-textfield-with-submit.tsx
index 0d25ab1b6c..481242946d 100644
--- a/web/components/config/form-textfield-with-submit.tsx
+++ b/web/components/config/form-textfield-with-submit.tsx
@@ -42,6 +42,7 @@ export default function TextFieldWithSubmit(props: TextFieldWithSubmitProps) {
configPath = '',
initialValue,
useTrim,
+ useTrimLead,
...textFieldProps // rest of props
} = props;
@@ -73,7 +74,7 @@ export default function TextFieldWithSubmit(props: TextFieldWithSubmitProps) {
if (onChange) {
onChange({
fieldName: changedFieldName,
- value: useTrim ? changedValue.trim() : changedValue,
+ value: useTrim ? changedValue.trim() : useTrimLead ? changedValue.replace(/^\s+/g,'') : changedValue,
});
}
};
diff --git a/web/components/config/form-textfield.tsx b/web/components/config/form-textfield.tsx
index ea71730cff..29afc6ebfb 100644
--- a/web/components/config/form-textfield.tsx
+++ b/web/components/config/form-textfield.tsx
@@ -29,6 +29,7 @@ export interface TextFieldProps {
tip?: string;
type?: string;
useTrim?: boolean;
+ useTrimLead?: boolean;
value?: string | number;
onBlur?: FieldUpdaterFunc;
onChange?: FieldUpdaterFunc;
diff --git a/web/utils/config-constants.tsx b/web/utils/config-constants.tsx
index 2ff13482b7..0845a9f363 100644
--- a/web/utils/config-constants.tsx
+++ b/web/utils/config-constants.tsx
@@ -56,6 +56,8 @@ export const TEXTFIELD_PROPS_SERVER_NAME = {
placeholder: 'Owncast site name', // like "gothland"
label: 'Name',
tip: 'The name of your Owncast server',
+ required: true,
+ useTrimLead: true,
};
export const TEXTFIELD_PROPS_STREAM_TITLE = {
apiPath: API_STREAM_TITLE,