Skip to content

Commit

Permalink
FORMS-16007: incorporating the review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrikha . authored and ci-build committed Jan 17, 2025
1 parent e7ceec5 commit 1a232d6
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,6 @@
restEndPointUrlTextBox = Utils.selectElement("input", './restEndpointPostUrl')[0],
restEndpointConfigPath = Utils.selectElement("input", './restEndpointConfigPath')[0];

if (!enableRestEndpointCheckboxElement) return;

if (enableRestEndpointCheckboxElement != null && enableRestEndpointCheckboxElement.checked == true) {
restEndPointSource.parent('div').parent('div').show();
Utils.showComponent(restEndPointSource, 'div');
Expand Down Expand Up @@ -498,12 +496,16 @@
function registerRestEndpointUrlValidator() {
$(window).adaptTo("foundation-registry").register("foundation.validation.validator", {
selector: "[data-rest-endpoint-url-validation]",
validate: function(el) {
var url = el.value;
var absoluteUrlPattern = /^(?:[a-z]+:)?\/\//i; // Pattern to match absolute URLs
validate: (el) => {
const url = el.value;

// Regex to validate absolute URLs starting with http:// or https:// only
const absoluteUrlPattern = /^(https?:\/\/)([a-z0-9\-]+\.)*[a-z0-9\-]+(\.[a-z]{2,})(:[0-9]{1,5})?(\/.*)?$/i;

if (!absoluteUrlPattern.test(url)) {
return Granite.I18n.getMessage("Enter a valid URL for the POST request. Ensure the URL starts with 'https://' or 'http://' and follows this structure: https://www.server.com/path/to/resource");
return Granite.I18n.getMessage(
"Enter a valid URL for the POST request. Ensure the URL starts with 'https://' or 'http://' and follows this structure: https://www.server.com/path/to/resource"
);
}
}
});
Expand Down

0 comments on commit 1a232d6

Please sign in to comment.