Fix ommitted port when constructing redirect URL
authorRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Fri, 30 Jun 2023 15:03:00 +0000 (16:03 +0100)
committerRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Fri, 30 Jun 2023 15:04:30 +0000 (16:04 +0100)
Form Builder can be configured to send a redirect after a submission
form has submitted. Before this change it rebuilt URLs with all the
parts except the port, causing failures on sites that use a non standard
port. After this change, a port is used if there is one.

ext/afform/core/ang/af/afForm.component.js

index 9951e5ddbdc8706c7bbe9158a63d42242dba6921..6584171873b4c64d15e71ef34293f75393f22439 100644 (file)
           if (url.indexOf('civicrm/') === 0) {
             url = CRM.url(url);
           } else if (url.indexOf('/') === 0) {
-            url = $location.protocol() + '://' + $location.host() + url;
+            let port = $location.port();
+            port = port ? `:${port}` : '';
+            url = `${$location.protocol()}://${$location.host()}${port}${url}`;
           }
           $window.location.href = url;
         }