Skip to content

Instantly share code, notes, and snippets.

@evert0n
Forked from alexanderGugel/domainhacks.js
Created February 2, 2018 17:34
Show Gist options
  • Save evert0n/59735238fdad81e6258bafc5fb7a2a4f to your computer and use it in GitHub Desktop.
Save evert0n/59735238fdad81e6258bafc5fb7a2a4f to your computer and use it in GitHub Desktop.
Domainhacks
var fs = require('fs');
var words = fs.readFileSync('/usr/share/dict/words', {
encoding: 'utf8'
}).split('\n');
var tlds = ['co', 'com', 'io', 'de', 'it'];
var results = [];
for (var i = 0; i < words.length; i++) {
var wordArray = words[i].split('');
for (var j = 0; j < tlds.length; j++) {
var tld = tlds[j];
var lastLetters = wordArray.slice(-tld.length).join('');
if (lastLetters === tld) {
wordArray.splice(-tld.length, 0, '.');
results.push(wordArray.join(''));
}
}
}
console.log(results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment