diff --git a/cypress/integration/nginxconfig_spec.js b/cypress/integration/nginxconfig_spec.js index 2d16076..d0a72d9 100644 --- a/cypress/integration/nginxconfig_spec.js +++ b/cypress/integration/nginxconfig_spec.js @@ -12,6 +12,12 @@ describe('nginxconfig.io', function () { }); it('should use passed params', function () { + cy.visit(root + '?0.domain=nginxconfig.io'); + cy.get('input.domain').should('have.value', 'nginxconfig.io'); + cy.get('#file-domain').contains('server_name nginxconfig.io;'); + }); + + it('should use legacy passed params', function () { cy.visit(root + '?domain=nginxconfig.io'); cy.get('input.domain').should('have.value', 'nginxconfig.io'); cy.get('#file-domain').contains('server_name nginxconfig.io;'); diff --git a/public/assets/js/app.js b/public/assets/js/app.js index 251a7e6..ce6a10c 100644 --- a/public/assets/js/app.js +++ b/public/assets/js/app.js @@ -217,14 +217,21 @@ var hashData = $location.search(); for (var key in hashData) { + var originalKey = key; + + // legacy + if (typeof $scope.data.sites[0][key] !== 'undefined') { + key = '0.' + key; + } + // handle false - if (hashData[key] === 'false') { - hashData[key] = false; + if (hashData[originalKey] === 'false') { + hashData[originalKey] = false; } // handle true - if ((hashData[key] === 'true' || hashData[key] === '') && typeof $scope.data[key] === 'boolean') { - hashData[key] = true; + if ((hashData[originalKey] === 'true' || hashData[originalKey] === '') && ($scope.data[originalKey] === 'boolean' || $scope.data.sites[0][originalKey] === 'boolean')) { + hashData[originalKey] = true; } // handle sites @@ -239,13 +246,13 @@ if ( $scope.data.sites[site][siteKey] !== undefined && - typeof $scope.data.sites[site][siteKey] === typeof hashData[key] + typeof $scope.data.sites[site][siteKey] === typeof hashData[originalKey] ) { $scope.isDirty = true; - $scope.data.sites[site][siteKey] = hashData[key]; + $scope.data.sites[site][siteKey] = hashData[originalKey]; gtag('event', key, { event_category: 'data_from_hash', - event_label: hashData[key], + event_label: hashData[originalKey], }); } } else if (