Preserve untouched example domains from query params
parent
4e34a9b6a9
commit
62178fd7d2
|
@ -151,7 +151,7 @@ limitations under the License.
|
||||||
computed: {
|
computed: {
|
||||||
...computedFromDefaults(defaults, 'security'), // Getters & setters for the delegated data
|
...computedFromDefaults(defaults, 'security'), // Getters & setters for the delegated data
|
||||||
hasWordPress() {
|
hasWordPress() {
|
||||||
return this.$parent.$parent.$data.domains.some(d => d.php.wordPressRules.computed);
|
return this.$parent.$parent.$data.domains.some(d => d && d.php.wordPressRules.computed);
|
||||||
},
|
},
|
||||||
hasUnsafeEval() {
|
hasUnsafeEval() {
|
||||||
return this.$props.data.contentSecurityPolicy.computed.includes('\'unsafe-eval\'');
|
return this.$props.data.contentSecurityPolicy.computed.includes('\'unsafe-eval\'');
|
||||||
|
|
|
@ -121,8 +121,8 @@ export default data => {
|
||||||
// If not a global setting and if this is an integer
|
// If not a global setting and if this is an integer
|
||||||
// Then, this is probably an old domain, so we'll try to convert it as such
|
// Then, this is probably an old domain, so we'll try to convert it as such
|
||||||
if (!isNaN(parseInt(key))) {
|
if (!isNaN(parseInt(key))) {
|
||||||
data.domains = data.domains || [];
|
data.domains = isObject(data.domains) ? data.domains : {};
|
||||||
data.domains.push(data[key]);
|
data.domains[key] = data[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,35 +130,35 @@ export default data => {
|
||||||
data.global = {...(data.global || {}), ...mappedGlobal};
|
data.global = {...(data.global || {}), ...mappedGlobal};
|
||||||
|
|
||||||
// Handle converting domain settings
|
// Handle converting domain settings
|
||||||
if ('domains' in data && (Array.isArray(data.domains) || isObject(data.domains))) {
|
if ('domains' in data && isObject(data.domains)) {
|
||||||
// Ensure we're working with an array
|
for (const key in data.domains) {
|
||||||
const values = isObject(data.domains) ? Object.values(data.domains) : data.domains;
|
// Don't include inherited props
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(data.domains, key)) continue;
|
||||||
|
|
||||||
for (let i = 0; i < values.length; i++) {
|
|
||||||
// Check this is an object
|
// Check this is an object
|
||||||
if (!isObject(values[i])) continue;
|
if (!isObject(data.domains[key])) continue;
|
||||||
|
|
||||||
// Hold any mapped data
|
// Hold any mapped data
|
||||||
const mappedData = {};
|
const mappedData = {};
|
||||||
|
|
||||||
// Handle converting old domain settings to new ones
|
// Handle converting old domain settings to new ones
|
||||||
for (const key in values[i]) {
|
for (const key2 in data.domains[key]) {
|
||||||
if (!Object.prototype.hasOwnProperty.call(values[i], key)) continue;
|
// Don't include inherited props
|
||||||
if (isObject(values[i][key])) continue;
|
if (!Object.prototype.hasOwnProperty.call(data.domains[key], key2)) continue;
|
||||||
|
|
||||||
|
// Don't convert objects
|
||||||
|
if (isObject(data.domains[key][key2])) continue;
|
||||||
|
|
||||||
// Map old settings to their new ones
|
// Map old settings to their new ones
|
||||||
if (key in domainMap) {
|
if (key2 in domainMap) {
|
||||||
const map = domainMap[key];
|
const map = domainMap[key2];
|
||||||
mappedData[map[0]] = mappedData[map[0]] || {};
|
mappedData[map[0]] = mappedData[map[0]] || {};
|
||||||
mappedData[map[0]][map[1]] = map.length < 3 ? values[i][key] : map[2](values[i][key]);
|
mappedData[map[0]][map[1]] = map.length < 3 ? data.domains[key][key2] : map[2](data.domains[key][key2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overwrite mapped properties
|
// Overwrite mapped properties
|
||||||
values[i] = {...values[i], ...mappedData};
|
data.domains[key] = {...data.domains[key], ...mappedData};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the updated domain data
|
|
||||||
data.domains = values;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,6 +54,7 @@ export default (query, domains, global, nextTick) => {
|
||||||
const data = qs.parse(query, {
|
const data = qs.parse(query, {
|
||||||
ignoreQueryPrefix: true,
|
ignoreQueryPrefix: true,
|
||||||
allowDots: true,
|
allowDots: true,
|
||||||
|
parseArrays: false,
|
||||||
decoder(value) {
|
decoder(value) {
|
||||||
value = decodeURIComponent(value);
|
value = decodeURIComponent(value);
|
||||||
|
|
||||||
|
@ -78,25 +79,23 @@ export default (query, domains, global, nextTick) => {
|
||||||
backwardsCompatibility(data);
|
backwardsCompatibility(data);
|
||||||
|
|
||||||
// Handle domains
|
// Handle domains
|
||||||
if ('domains' in data) {
|
if ('domains' in data && isObject(data.domains)) {
|
||||||
// Check its an array or object
|
// Work through all valid integer keys in the object
|
||||||
if (Array.isArray(data.domains) || isObject(data.domains)) {
|
const keys = Object.keys(data.domains).map(x => parseInt(x)).filter(x => !isNaN(x));
|
||||||
// Ensure we're working with an array
|
for (let i = 0; i < Math.max(...keys) + 1; i++) {
|
||||||
const values = isObject(data.domains) ? Object.values(data.domains) : data.domains;
|
// If the key doesn't exist or this isn't a valid object, assume it was an untouched example domain
|
||||||
|
if (!keys.includes(i) || !isObject(data.domains[i])) {
|
||||||
// Work through each potential domain
|
domains.push(clone(Domain.delegated));
|
||||||
for (const domainData of values) {
|
continue;
|
||||||
// Check this is an object
|
|
||||||
if (!isObject(domainData)) continue;
|
|
||||||
|
|
||||||
// Create a new domain (assume it has had custom user settings)
|
|
||||||
const domainImported = clone(Domain.delegated);
|
|
||||||
domainImported.hasUserInteraction = true;
|
|
||||||
domains.push(domainImported);
|
|
||||||
|
|
||||||
// Apply the initial values on the next Vue tick, once the watchers are ready
|
|
||||||
nextTick(() => applyCategories(domainData, domainImported));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a new domain (assume it has had custom user settings)
|
||||||
|
const domainImported = clone(Domain.delegated);
|
||||||
|
domainImported.hasUserInteraction = true;
|
||||||
|
domains.push(domainImported);
|
||||||
|
|
||||||
|
// Apply the initial values on the next Vue tick, once the watchers are ready
|
||||||
|
nextTick(() => applyCategories(data.domains[i], domainImported));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If no configured domains, add a single default
|
// If no configured domains, add a single default
|
||||||
|
|
Loading…
Reference in New Issue