-
Notifications
You must be signed in to change notification settings - Fork 255
/
add.js
44 lines (34 loc) · 1.2 KB
/
add.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { writeFileSync, readFileSync } = require('fs')
const _ = require('lodash')
var index = require('./index')
var wildcard = require('./wildcard')
// Add new domains
const newDomains = readFileSync('./contributions/index.txt').toString().split("\n").filter(d => d)
index = _.concat(index, newDomains)
const newWildcardDomains = readFileSync('./contributions/wildcard.txt').toString().split("\n").filter(d => d)
wildcard = _.concat(wildcard, newWildcardDomains)
// Remove empty strings
index = index.filter(d => d)
wildcard = wildcard.filter(d => d)
// Lowercase
index = index.map(domain => { return _.toLower(domain) })
wildcard = wildcard.map(domain => { return _.toLower(domain) })
// Sort
index.sort()
wildcard.sort()
// Dedupe
index = _.uniq(index)
wildcard = _.uniq(wildcard)
// Remove wildcards
var regexp = new RegExp(/(.+(?:\.[\w-]+\.[\w-]+)+)$/)
index = index
.filter(domain => {
if (regexp.test(domain)) {
return ! wildcard.filter(wildcard => {
return _.endsWith(domain, wildcard)
}).length
}
return true
})
writeFileSync('index.json', JSON.stringify(index, null, 2))
writeFileSync('wildcard.json', JSON.stringify(wildcard, null, 2))