Closed juananpe closed 1 year ago
For this example:
const hosts = links.map(a => a.href.split(':')[1].split('/')[0]).unique()
I think that the number to index the array generated by the second split should be 2 instead of 0.
2
0
A small proof of my point follows. Here, using index 0 after the split, will yield an empty result:
let links = ['https://ikasten.io/cc/c.html', 'https://ehu.eus/bb/b.html', 'https://ikasten.io/aa/as.html'] const hosts = links.map(a=> console.log( a.split(':')[1].split('/')[0] ) )
While using 2 will yield the hostnames (on which we could apply the unique() function)
let links = ['https://ikasten.io/cc/c.html', 'https://ehu.eus/bb/b.html', 'https://ikasten.io/aa/as.html'] const hosts = links.map(a=> console.log( a.split(':')[1].split('/')[2] ) ) ikasten.io ehu.eus ikasten.io
For this example:
I think that the number to index the array generated by the second split should be
2
instead of0
.A small proof of my point follows. Here, using index
0
after the split, will yield an empty result:While using
2
will yield the hostnames (on which we could apply the unique() function)