39 lines
755 B
JavaScript
39 lines
755 B
JavaScript
const querystring = require('querystring');
|
|
const url = require('url');
|
|
|
|
let list = [
|
|
|
|
{
|
|
|
|
"count": 100,
|
|
"feed_url": "https://www.changedetection.com/accountfeed.xml?feedid=438821327538204"
|
|
}
|
|
|
|
];
|
|
|
|
|
|
let newArray = list.map((item) => {
|
|
let u = url.parse(item.feed_url);
|
|
let newUrl = item.feed_url;
|
|
if (u.host !== '') {
|
|
newUrl = `http://52.211.105.9:6566/${querystring.escape(item.feed_url)}`;
|
|
}
|
|
return newUrl
|
|
|
|
});
|
|
|
|
console.log('New array', newArray.length);
|
|
let unique = [];
|
|
|
|
for (let item of newArray) {
|
|
if (unique.indexOf(item) === -1) {
|
|
unique.push(item);
|
|
}
|
|
}
|
|
console.log('unique', unique.length);
|
|
|
|
unique = unique.map((item) => {
|
|
return {'count':100, 'feed_url':item};
|
|
})
|
|
console.log(JSON.stringify(unique));
|