mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-17 10:14:32 +00:00
Fixes diff issues with sanitizations
This commit is contained in:
1 parent
77f0979100
commit
e69eff33a3
2 files changed
+18
-13
No files matched your search
@@ -12,7 +12,7 @@ const toHostList = R.chain(data => {
|
|||||||
(Array.isArray(urls) ? urls : [urls]).map(url => ({
|
(Array.isArray(urls) ? urls : [urls]).map(url => ({
|
||||||
name: data.name,
|
name: data.name,
|
||||||
type: recordType,
|
type: recordType,
|
||||||
address: url,
|
address: (recordType === 'CNAME' ? `${url}`.toLowerCase() : `${url}`).replace(/\/$/g, ''),
|
||||||
ttl: TTL,
|
ttl: TTL,
|
||||||
}))
|
}))
|
||||||
, rs);
|
, rs);
|
||||||
|
|||||||
+17
-12
@@ -10,23 +10,24 @@ const recordToRedirection = ({ name, address }) => ({
|
|||||||
redirect_www: 0,
|
redirect_www: 0,
|
||||||
});
|
});
|
||||||
const recordToZone = ({ name, type, address, ...rec }) => ({
|
const recordToZone = ({ name, type, address, ...rec }) => ({
|
||||||
...rec,
|
...rec, //line
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
address,
|
...(type === 'CNAME' ? { cname: address } : { address }),
|
||||||
cname: type === 'CNAME' ? address : undefined,
|
});
|
||||||
})
|
|
||||||
|
|
||||||
const zoneToRecord = ({ name, type, cname, address, ...host }) => ({
|
const cleanName = name => `${name}`.replace(new RegExp(`\.${DOMAIN_DOMAIN}\.?$`), '').toLowerCase();
|
||||||
|
|
||||||
|
const zoneToRecord = ({ name, type, cname, address, record, ...host }) => ({
|
||||||
...host,
|
...host,
|
||||||
name: `${name}`,
|
name: cleanName(name),
|
||||||
type: `${type}`,
|
type: `${type}`,
|
||||||
address: `${cname || address}`.replace(/\.$/g, ''),
|
address: `${cname || address || record}`.replace(/\.$/g, '').toLowerCase(),
|
||||||
});
|
});
|
||||||
const redirectionToRecord = ({ domain, destination }) => ({
|
const redirectionToRecord = ({ domain, destination }) => ({
|
||||||
name: `${domain}`.replace('.' + DOMAIN_DOMAIN, ''),
|
name: cleanName(domain),
|
||||||
type: 'URL',
|
type: 'URL',
|
||||||
address: `${destination}`,
|
address: `${destination}`.replace(/\/$/g, ''),
|
||||||
});
|
});
|
||||||
|
|
||||||
const getHostKey = host => `${host.name}##${host.type}`;
|
const getHostKey = host => `${host.name}##${host.type}`;
|
||||||
@@ -79,7 +80,12 @@ const executeBatch = (batches) => batches.reduce((promise, batch) => {
|
|||||||
console.log('>>> Running batch', batch.length);
|
console.log('>>> Running batch', batch.length);
|
||||||
return Promise.all(batch.map(fn => fn().catch(e => {
|
return Promise.all(batch.map(fn => fn().catch(e => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
})));
|
}))).then(values => {
|
||||||
|
const results = values.map(R.pathOr([], ['cpanelresult', 'data', 0]));
|
||||||
|
const failed = results.filter(x => (x.result || {}).status != 1);
|
||||||
|
console.log(`${values.length - failed.length}/${values.length}`);
|
||||||
|
failed.length && console.log(failed);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
|
|
||||||
@@ -90,9 +96,8 @@ const getDomainService = ({ cpanel }) => {
|
|||||||
const fetchRedirections = () => cpanel.redirection.fetch().then(R.map(redirectionToRecord));
|
const fetchRedirections = () => cpanel.redirection.fetch().then(R.map(redirectionToRecord));
|
||||||
|
|
||||||
const addZoneRecord = lazyTask(R.compose(cpanel.zone.add, recordToZone));
|
const addZoneRecord = lazyTask(R.compose(cpanel.zone.add, recordToZone));
|
||||||
const addRedirection = lazyTask(R.compose(cpanel.redirection.add, recordToRedirection));
|
|
||||||
|
|
||||||
const editZoneRecord = lazyTask(R.compose(cpanel.zone.edit, recordToZone));
|
const editZoneRecord = lazyTask(R.compose(cpanel.zone.edit, recordToZone));
|
||||||
|
const addRedirection = lazyTask(R.compose(cpanel.redirection.add, recordToRedirection));
|
||||||
const editRedirection = lazyTask(R.compose(cpanel.redirection.edit, recordToRedirection));
|
const editRedirection = lazyTask(R.compose(cpanel.redirection.edit, recordToRedirection));
|
||||||
|
|
||||||
const getHosts = async () => {
|
const getHosts = async () => {
|
||||||
|
|||||||
Reference in new issue
Block a user