Skip to content

Commit

Permalink
remove advanced validation from the URL control
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-o committed Aug 16, 2024
1 parent c39268a commit 5946c42
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions controls/url/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ addFilter('lzb.editor.control.url.render', 'lzb.editor', (render, props) => (

/**
* Required check.
* Just check for empty value. Previously we used advanced URL validation, but we can't restrict values like '#' or 'relative-url-string'.
*
* @param {Object} validationData
* @param {number} value
Expand All @@ -60,17 +61,6 @@ function validate(validationData, value) {
return { valid: false };
}

if (
!/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(
value
)
) {
return {
valid: false,
message: 'Please enter a valid URL.',
};
}

return validationData;
}
addFilter('lzb.editor.control.url.validate', 'lzb.editor', validate);

0 comments on commit 5946c42

Please sign in to comment.