handle legacy get parameters
parent
e56d195338
commit
8992606124
|
@ -12,6 +12,12 @@ describe('nginxconfig.io', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use passed params', 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.visit(root + '?domain=nginxconfig.io');
|
||||||
cy.get('input.domain').should('have.value', 'nginxconfig.io');
|
cy.get('input.domain').should('have.value', 'nginxconfig.io');
|
||||||
cy.get('#file-domain').contains('server_name nginxconfig.io;');
|
cy.get('#file-domain').contains('server_name nginxconfig.io;');
|
||||||
|
|
|
@ -217,14 +217,21 @@
|
||||||
var hashData = $location.search();
|
var hashData = $location.search();
|
||||||
|
|
||||||
for (var key in hashData) {
|
for (var key in hashData) {
|
||||||
|
var originalKey = key;
|
||||||
|
|
||||||
|
// legacy
|
||||||
|
if (typeof $scope.data.sites[0][key] !== 'undefined') {
|
||||||
|
key = '0.' + key;
|
||||||
|
}
|
||||||
|
|
||||||
// handle false
|
// handle false
|
||||||
if (hashData[key] === 'false') {
|
if (hashData[originalKey] === 'false') {
|
||||||
hashData[key] = false;
|
hashData[originalKey] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle true
|
// handle true
|
||||||
if ((hashData[key] === 'true' || hashData[key] === '') && typeof $scope.data[key] === 'boolean') {
|
if ((hashData[originalKey] === 'true' || hashData[originalKey] === '') && ($scope.data[originalKey] === 'boolean' || $scope.data.sites[0][originalKey] === 'boolean')) {
|
||||||
hashData[key] = true;
|
hashData[originalKey] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle sites
|
// handle sites
|
||||||
|
@ -239,13 +246,13 @@
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$scope.data.sites[site][siteKey] !== undefined &&
|
$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.isDirty = true;
|
||||||
$scope.data.sites[site][siteKey] = hashData[key];
|
$scope.data.sites[site][siteKey] = hashData[originalKey];
|
||||||
gtag('event', key, {
|
gtag('event', key, {
|
||||||
event_category: 'data_from_hash',
|
event_category: 'data_from_hash',
|
||||||
event_label: hashData[key],
|
event_label: hashData[originalKey],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
|
|
Loading…
Reference in New Issue