Components/create-edit-modal: change url validation regex

This commit is contained in:
Toast 2025-02-06 19:52:37 +01:00
parent a52a76b6d0
commit 1c9b1487de

View file

@ -63,7 +63,7 @@ export class CreateEditModalComponent {
} }
protected addImageControl(value: string = "") { protected addImageControl(value: string = "") {
const urlRegex: string = '(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?' const urlRegex = "(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,})"
this.images.push(new FormControl(value, [Validators.required, Validators.pattern(urlRegex)])) this.images.push(new FormControl(value, [Validators.required, Validators.pattern(urlRegex)]))
} }