domain-hound 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/clis/domain-check/confirm.mjs +4 -2
- package/clis/domain-check/index.mjs +62 -19
- package/clis/domain-check/name-search.mjs +73 -12
- package/clis/domain-check/registry.mjs +149 -36
- package/clis/domain-check/traction.mjs +2 -2
- package/clis/domain-check/triage-sources.mjs +8 -1
- package/clis/domain-check/triage.mjs +48 -26
- package/display.mjs +191 -62
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/server.json +5 -5
- package/server.mjs +21 -13
|
@@ -6,7 +6,8 @@ const budget = 20_500;
|
|
|
6
6
|
const shopBudget = 10_000;
|
|
7
7
|
const cacheLifetime = 15 * 60_000;
|
|
8
8
|
const userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0 Safari/537.36';
|
|
9
|
-
|
|
9
|
+
// Shops write whole-dollar prices without cents too ("$8" at Dynadot).
|
|
10
|
+
const dollars = String.raw`\$\s*(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d{2})?`;
|
|
10
11
|
const priceLine = new RegExp('^' + dollars + '$');
|
|
11
12
|
const dynadotPrices = new RegExp('^(?:' + dollars + '){1,2}$');
|
|
12
13
|
const lastPrice = new RegExp(dollars + '$');
|
|
@@ -16,7 +17,8 @@ const namecheapPrice = new RegExp('^(' + dollars + ')/yr$', 'i');
|
|
|
16
17
|
const namecheapRenewal = new RegExp('^Renews at (' + dollars + ')/yr\\.?$', 'i');
|
|
17
18
|
const cloudflareQuote = new RegExp('^Buy now: ([a-z0-9.-]+) for (' + dollars + ')\\. Renews at (' + dollars + ') per year\\.$', 'i');
|
|
18
19
|
const taken = /^(?:Taken|Registered in \d{4})$/i;
|
|
19
|
-
|
|
20
|
+
// "Premium", "Premium domain", and Dynadot's "Registry Premium" for a price the registry sets.
|
|
21
|
+
const premiumLabel = /^(?:Registry\s+)?Premium(?:\s+(?:domain|name))?$/i;
|
|
20
22
|
const trackerRoots = [
|
|
21
23
|
'google-analytics.com', 'googletagmanager.com', 'doubleclick.net', 'googlesyndication.com',
|
|
22
24
|
'facebook.net', 'facebook.com', 'nr-data.net', 'newrelic.com', 'crazyegg.com',
|
|
@@ -4,8 +4,9 @@ import { pathToFileURL } from 'node:url';
|
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
5
|
import { apiShops, cachedSignals, confirmDomain, confirmingShops, lightConfirm } from './confirm.mjs';
|
|
6
6
|
import { appStoreSearchLink, googleSearchLink, nameCheckLines, playSearchLink } from './google-search.mjs';
|
|
7
|
-
import { canRecommend, eligibilityNotes, mergeQuote, nameCandidates, normalizeName, pickName,
|
|
8
|
-
searchCandidates, searchName, termCosts, validEligibility, validEndings,
|
|
7
|
+
import { asciiDomain, canRecommend, defaultEndings, eligibilityNotes, listQuote, mergeQuote, nameCandidates, normalizeName, pickName,
|
|
8
|
+
premiumRisk, rankName, registrationStatus, searchCandidates, searchName, termCosts, unicodeName, validEligibility, validEndings,
|
|
9
|
+
withPremiumRisk, withoutListPrice } from './name-search.mjs';
|
|
9
10
|
import { bundledCatalog, catalogOffers, datedListPrices, isListPriceUsable, loadCachedCatalog, refreshPrices } from './price-catalog.mjs';
|
|
10
11
|
import { lookupRegistrations } from './registry.mjs';
|
|
11
12
|
import { namingRecipe, purchaseLine } from './naming-method.mjs';
|
|
@@ -65,10 +66,12 @@ async function openShop(args) {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
export function normalize(input) {
|
|
68
|
-
const
|
|
69
|
+
const typed = typeof input === 'string' ? input.trim().toLowerCase()
|
|
69
70
|
.replace(/^[a-z][a-z\d+.-]*:\/\//, '')
|
|
70
71
|
.split(/[/?#]/, 1)[0]
|
|
71
72
|
.replace(/^www\.(?=[^.]+\.)/, '') : '';
|
|
73
|
+
// A Unicode domain is checked as its punycode form, never with letters removed.
|
|
74
|
+
const domain = asciiDomain(typed) ?? '';
|
|
72
75
|
const labels = domain.split('.');
|
|
73
76
|
const label = /^[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?$/;
|
|
74
77
|
const tld = /^(?:[a-z]{2,63}|xn--[a-z\d](?:[a-z\d-]{0,57}[a-z\d])?)$/;
|
|
@@ -192,7 +195,9 @@ export async function checkDomain(input, {
|
|
|
192
195
|
// Porkbun's own quote above its list price, without a premium flag, may still be premium.
|
|
193
196
|
const porkbunList = pricing?.pricing?.[tld] ? catalogPrice(pricing.pricing[tld].registration) : null;
|
|
194
197
|
const porkbunPremium = confirmed && (confirmed.premium || (porkbunList != null && confirmed.price > porkbunList + 0.01));
|
|
195
|
-
|
|
198
|
+
// A short name may be premium: no list price unless a shop marks its quote as standard.
|
|
199
|
+
const risk = registry.status === 'free' && premiumRisk(domain) && shopQuote?.standard !== true && !porkbunPremium;
|
|
200
|
+
const premium = registry.signal === 'premium' || shopQuote?.status === 'premium' || porkbunPremium || risk;
|
|
196
201
|
const reserved = registry.signal === 'reserved' || shopQuote?.status === 'reserved';
|
|
197
202
|
const verdict = shopQuote?.status === 'taken' || registry.status === 'taken' ? 'taken'
|
|
198
203
|
: reserved ? 'reserved' : premium ? 'premium' : confirmed || shopQuote?.status === 'confirmed' ? 'confirmed' : registry.status;
|
|
@@ -209,8 +214,9 @@ export async function checkDomain(input, {
|
|
|
209
214
|
confirmed: confirmed ? { ...confirmed, ...(!confirmed.premium && { possible: true }) } : null,
|
|
210
215
|
...(shopQuote && { shopQuote }), best, cheapestToday: null, offers: best ? [best] : [], stale: false,
|
|
211
216
|
priceDate: null, nok, vatNorway,
|
|
217
|
+
...(risk && !quoted && { premiumRisk: true }),
|
|
212
218
|
notes: [registry.reason, reserved ? 'Not offered for registration; check at the shop'
|
|
213
|
-
: best ? null : 'Premium, price at shop'].filter(Boolean),
|
|
219
|
+
: best ? null : risk && !registry.signal ? 'May be premium, price at shop' : 'Premium, price at shop'].filter(Boolean),
|
|
214
220
|
buyUrl: shopSearchUrl(shopId, domain),
|
|
215
221
|
};
|
|
216
222
|
}
|
|
@@ -282,6 +288,9 @@ const agentLegend = {
|
|
|
282
288
|
y3: 'Payments due in three years, USD ex. VAT',
|
|
283
289
|
term: 'Years per payment when more than one',
|
|
284
290
|
jump: 'Renewal over twice the first annual price',
|
|
291
|
+
risk: 'Short name: may be premium, price at the shop',
|
|
292
|
+
likely_free: 'Registry silent, DNS has no delegation: likely free, confirm at a shop',
|
|
293
|
+
likely_taken: 'Registry silent, DNS has a delegation: likely taken',
|
|
285
294
|
};
|
|
286
295
|
const googleEndings = new Set(['app', 'dev']);
|
|
287
296
|
// Playwright is optional. Without it (or its browser) the live shop check cannot run at all.
|
|
@@ -315,7 +324,8 @@ function agentPrice({ firstPayment: now, renewalPayment: renew, threeYear: y3, m
|
|
|
315
324
|
// The shop quote time as HH:MM UTC.
|
|
316
325
|
const quoteClock = value => typeof value === 'string' ? value.match(/T(\d{2}:\d{2})/)?.[1] ?? null : null;
|
|
317
326
|
|
|
318
|
-
function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimited = false, liveCheck = null
|
|
327
|
+
function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimited = false, liveCheck = null,
|
|
328
|
+
{ eligible, otherEndings } = {}) {
|
|
319
329
|
const buyUrlTemplate = {};
|
|
320
330
|
const shopCheckWhy = {};
|
|
321
331
|
const listPrices = {};
|
|
@@ -324,7 +334,7 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
324
334
|
let priceListDate;
|
|
325
335
|
let best;
|
|
326
336
|
for (const { name, results } of groups) {
|
|
327
|
-
const taken = [], resale = [], free = [], shop_check = [];
|
|
337
|
+
const taken = [], resale = [], free = [], shop_check = [], likelyFree = [], likelyTaken = [];
|
|
328
338
|
for (const row of results) {
|
|
329
339
|
checkedEndings.add(row.tld);
|
|
330
340
|
const d = row.exact ? row.tld : row.domain;
|
|
@@ -332,11 +342,14 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
332
342
|
const premium = row.status === 'premium';
|
|
333
343
|
const confirmed = row.status === 'confirmed' || (premium && row.price != null && row.source === 'shop');
|
|
334
344
|
const price = agentPrice({ ...row, shop });
|
|
335
|
-
|
|
345
|
+
// A taken exact domain can show a standard ending benchmark. For .ai this explains its two-year renewal.
|
|
346
|
+
const benchmark = !batch && row.exact && row.status === 'taken' && row.listPrice
|
|
347
|
+
&& (row.tld === 'ai' || !premiumRisk(row.domain));
|
|
348
|
+
if ((batch || benchmark) && !confirmed && !premium && row.status !== 'reserved' && listPrices[d]?.now == null) {
|
|
336
349
|
const listed = row.listPrice ? agentPrice(row.listPrice) : price;
|
|
337
350
|
if (Object.keys(listed).length) listPrices[d] = listed;
|
|
338
351
|
}
|
|
339
|
-
const date = (row.priceCheckedAt ?? (batch ? row.listPrice?.checkedAt : null))?.slice(0, 10);
|
|
352
|
+
const date = (row.priceCheckedAt ?? (batch || benchmark ? row.listPrice?.checkedAt : null))?.slice(0, 10);
|
|
340
353
|
// Use the oldest list date among the displayed estimates.
|
|
341
354
|
if (date && (priceListDate === undefined || date < priceListDate)) priceListDate = date;
|
|
342
355
|
if (row.status === 'taken') {
|
|
@@ -349,8 +362,8 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
349
362
|
buyUrlTemplate[shop] = url + '{domain}' + suffix;
|
|
350
363
|
}
|
|
351
364
|
if (premium && !confirmed) {
|
|
352
|
-
// Premium without a price: free to register, but only the shop shows the price.
|
|
353
|
-
free.push({ d, s: 'prem', ...(shop && { shop }) });
|
|
365
|
+
// Premium without a price: free to register, but only the shop shows the price. A short name may be premium.
|
|
366
|
+
free.push({ d, s: 'prem', ...(shop && { shop }), ...(row.premium === 'risk' && { risk: true }) });
|
|
354
367
|
continue;
|
|
355
368
|
}
|
|
356
369
|
if (row.status === 'reserved') {
|
|
@@ -362,6 +375,8 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
362
375
|
if (!batch && row.status === 'check-at-shop' && price.now != null) listPrices[d] = price;
|
|
363
376
|
shop_check.push(d);
|
|
364
377
|
shopCheckWhy[d] ??= shopCheckReason(row, rateLimited);
|
|
378
|
+
if (row.likely === 'free') likelyFree.push(d);
|
|
379
|
+
if (row.likely === 'taken') likelyTaken.push(d);
|
|
365
380
|
continue;
|
|
366
381
|
}
|
|
367
382
|
// A batch row repeats its ending's standard price only when it differs.
|
|
@@ -369,7 +384,7 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
369
384
|
const at = confirmed ? quoteClock(row.quotedAt ?? row.checkedAt) : null;
|
|
370
385
|
free.push({ d, s: confirmed ? 'ok' : 'nc', ...(!standard && price), ...(premium && { prem: row.premium ?? true }),
|
|
371
386
|
...(at && { at }) });
|
|
372
|
-
if (confirmed && !premium) {
|
|
387
|
+
if (confirmed && !premium && canRecommend(row.tld, eligible) && !premiumRisk(row.domain)) {
|
|
373
388
|
const { now, renew, y3, term, jump } = price;
|
|
374
389
|
const buyUrl = row.buyUrl ?? shopSearchUrl(shopId, row.domain);
|
|
375
390
|
// The cheapest confirmed quote is the pick; rows are already sorted by first payment within a name.
|
|
@@ -381,8 +396,11 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
381
396
|
...(shop && { shop }), ...(buyUrl && { buyUrl }) };
|
|
382
397
|
}
|
|
383
398
|
}
|
|
384
|
-
|
|
385
|
-
|
|
399
|
+
const unicode = unicodeName(name);
|
|
400
|
+
byName.set(name, { name, ...(unicode && { unicode }), ...(taken.length && { taken }), ...(resale.length && { resale }),
|
|
401
|
+
...(free.length && { free }), ...(shop_check.length && { shop_check }),
|
|
402
|
+
// Subsets of shop_check with a DNS likelihood; only a registry or shop settles them.
|
|
403
|
+
...(likelyFree.length && { likely_free: likelyFree }), ...(likelyTaken.length && { likely_taken: likelyTaken }) });
|
|
386
404
|
}
|
|
387
405
|
const result = {
|
|
388
406
|
...(!batch && names[0].includes('.') && {
|
|
@@ -390,12 +408,14 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
390
408
|
}),
|
|
391
409
|
complete, checkedAt, ...(priceListDate && { priceListDate }), ...(best && { best }),
|
|
392
410
|
eligibility: eligibilityNotes([...checkedEndings]),
|
|
411
|
+
...(eligible?.length && { eligible }),
|
|
393
412
|
names: names.map(name => byName.get(name)),
|
|
394
413
|
legend: agentLegend,
|
|
395
414
|
...(Object.keys(buyUrlTemplate).length && { buyUrlTemplate }),
|
|
396
415
|
...(Object.keys(shopCheckWhy).length && { shopCheckWhy }),
|
|
397
416
|
// The registry and list-price evidence above stays; this only says the shop quote could not be checked.
|
|
398
417
|
...(liveCheck && !best && { liveCheck }),
|
|
418
|
+
...(otherEndings && Object.keys(otherEndings).length && { otherEndings }),
|
|
399
419
|
};
|
|
400
420
|
if (Object.keys(listPrices).length) {
|
|
401
421
|
result.listPrices = listPrices;
|
|
@@ -446,7 +466,8 @@ export async function agentResult(input, options = {}) {
|
|
|
446
466
|
googleEndings.has(row.tld) && /HTTP 429/.test(row.registryReason ?? '')));
|
|
447
467
|
if (batch) rateLimited = await retryGoogle(fast, remaining, options) || rateLimited;
|
|
448
468
|
const rows = fast.groups.flatMap(group => group.results);
|
|
449
|
-
const targets = domain ? rows.filter(row =>
|
|
469
|
+
const targets = domain ? rows.filter(row => canRecommend(row.tld, options.eligible)
|
|
470
|
+
&& ['probably-free', 'check-at-shop', 'premium'].includes(row.status))
|
|
450
471
|
: lightTargets(rows, options.eligible);
|
|
451
472
|
const [candidate] = targets;
|
|
452
473
|
// A Google retry can settle every row that the first pass left waiting.
|
|
@@ -492,8 +513,29 @@ export async function agentResult(input, options = {}) {
|
|
|
492
513
|
const apply = row => quotes.has(row.domain) ? mergeQuote(row, quotes.get(row.domain)) : row;
|
|
493
514
|
const rankedGroups = fast.groups.map(({ name, results }) => ({ name, results: rankName(results.map(apply)) }));
|
|
494
515
|
const checkedAt = options.now?.toISOString() ?? new Date().toISOString();
|
|
516
|
+
// An exact .com gets the standard list prices of the other endings as one benchmark line, with no extra lookups.
|
|
517
|
+
const exactCom = names.length === 1 && names[0].endsWith('.com') ? names[0] : null;
|
|
518
|
+
const otherEndings = exactCom ? await endingBenchmarks(exactCom, options) : null;
|
|
495
519
|
return compactAgentResult(rankedGroups, names, complete, checkedAt, batch, rateLimited,
|
|
496
|
-
options.browser ? liveCheckFor(candidate, quote) : null);
|
|
520
|
+
options.browser ? liveCheckFor(candidate, quote) : null, { eligible: options.eligible, otherEndings });
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// The cheapest standard list price of each other ending for this label, from the saved or bundled price list.
|
|
524
|
+
// A short label may be premium, so it gets no benchmark.
|
|
525
|
+
async function endingBenchmarks(domain, options) {
|
|
526
|
+
const label = domain.slice(0, domain.indexOf('.'));
|
|
527
|
+
if (premiumRisk(label)) return null;
|
|
528
|
+
const now = options.now ?? new Date();
|
|
529
|
+
const bundled = options.bundledCatalog === undefined ? bundledCatalog : options.bundledCatalog;
|
|
530
|
+
const catalog = await loadCachedCatalog(options.directory).catch(() => null);
|
|
531
|
+
const prices = {};
|
|
532
|
+
for (const tld of defaultEndings.filter(ending => ending !== 'com' && canRecommend(ending, options.eligible))) {
|
|
533
|
+
const quote = listQuote(catalog, { domain: label + '.' + tld, tld }, now, bundled);
|
|
534
|
+
if (quote.price == null) continue;
|
|
535
|
+
const costs = termCosts(tld, quote.price, quote.renewal);
|
|
536
|
+
prices[tld] = agentPrice({ ...costs, renewalJump: quote.renewal > 2 * quote.price, shop: quote.shop });
|
|
537
|
+
}
|
|
538
|
+
return prices;
|
|
497
539
|
}
|
|
498
540
|
|
|
499
541
|
// Give unresolved .app and .dev rows one bounded registry retry with the batch time that is left.
|
|
@@ -528,13 +570,14 @@ async function retryGoogle(fast, remaining, options) {
|
|
|
528
570
|
const status = registrationStatus(answer);
|
|
529
571
|
if (status === 'check-at-shop') {
|
|
530
572
|
if (/HTTP 429/.test(answer.reason ?? '')) limited = true;
|
|
531
|
-
return { ...row, registryReason: answer.reason ?? row.registryReason };
|
|
573
|
+
return { ...row, registryReason: answer.reason ?? row.registryReason, ...(answer.likely && { likely: answer.likely }) };
|
|
532
574
|
}
|
|
533
|
-
const
|
|
575
|
+
const { likely, ...open } = row;
|
|
576
|
+
const settled = { ...open, status, source: answer.source, registryReason: undefined, forSale: Boolean(answer.forSale),
|
|
534
577
|
checkedAt: answer.checkedAt ?? (options.now ?? new Date()).toISOString() };
|
|
535
578
|
if (status === 'premium') return { ...withoutListPrice(settled, status), premium: true };
|
|
536
579
|
if (status === 'reserved') return withoutListPrice(settled, status, answer.reason);
|
|
537
|
-
if (status !== 'taken') return settled;
|
|
580
|
+
if (status !== 'taken') return withPremiumRisk(settled);
|
|
538
581
|
const { price, renewal, shop, priceCheckedAt } = row;
|
|
539
582
|
for (const key of ['price', 'renewal', 'shop', 'priceSource', 'priceCheckedAt', 'buyUrl']) delete settled[key];
|
|
540
583
|
return price == null ? settled : { ...settled, listPrice: { shop, checkedAt: priceCheckedAt,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { domainToASCII, domainToUnicode } from 'node:url';
|
|
1
2
|
import { checkDomainSite } from './com-site.mjs';
|
|
2
3
|
import { cachedSignals, confirmingShops } from './confirm.mjs';
|
|
3
4
|
import { bundledCatalog, datedListPrices, getNameCatalog, loadCachedCatalog, targetEndings } from './price-catalog.mjs';
|
|
4
5
|
import { linkable, shopSearchUrl } from './prices.mjs';
|
|
5
6
|
import { lookupRegistrations } from './registry.mjs';
|
|
7
|
+
import { foldLatin } from './triage-sources.mjs';
|
|
6
8
|
|
|
7
9
|
const checked = '2026-11-23';
|
|
8
10
|
const facts = {
|
|
@@ -11,6 +13,7 @@ const facts = {
|
|
|
11
13
|
source: 'https://www.namecheap.com/domains/registration/cctld/ai/', checked,
|
|
12
14
|
},
|
|
13
15
|
no: {
|
|
16
|
+
need: 'Norwegian org/ID',
|
|
14
17
|
note: 'Norwegian address plus organization number or personal ID required',
|
|
15
18
|
eligibility: 'Norwegian organization or eligible individual, with a Norwegian postal address',
|
|
16
19
|
source: 'https://www.norid.no/en/om-domenenavn/regelverk-for-no/', checked,
|
|
@@ -43,6 +46,11 @@ export function canRecommend(tld, eligible = []) {
|
|
|
43
46
|
return !facts[tld]?.eligibility || eligible.includes(tld);
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
// What a buyer needs for a restricted ending, in a few words: "Norwegian org/ID".
|
|
50
|
+
export function eligibilityNeed(tld) {
|
|
51
|
+
return facts[tld]?.eligibility ? facts[tld].need ?? 'eligibility' : null;
|
|
52
|
+
}
|
|
53
|
+
|
|
46
54
|
export function eligibilityNotes(endings) {
|
|
47
55
|
const notes = Object.fromEntries(restrictedEndings.filter(tld => endings.includes(tld))
|
|
48
56
|
.map(tld => [tld, facts[tld].note]));
|
|
@@ -54,16 +62,65 @@ export function validEndings(endings) {
|
|
|
54
62
|
&& endings.every(ending => targetEndings.includes(ending));
|
|
55
63
|
}
|
|
56
64
|
|
|
65
|
+
// One DNS label for a name. Spaces and punctuation go; letters never do. A name with non-ASCII letters (æ, ø, å, é)
|
|
66
|
+
// becomes its punycode label (xn--...), the form registries and shops use for that exact spelling.
|
|
57
67
|
export function normalizeName(input) {
|
|
58
68
|
if (typeof input !== 'string' || /[./\\]/.test(input)) return null;
|
|
59
|
-
const name = input.normalize('
|
|
60
|
-
return label.test(name) ? name : null;
|
|
69
|
+
const name = input.normalize('NFC').toLowerCase().replace(/[^\p{L}\p{N}\p{M}-]/gu, '');
|
|
70
|
+
if (/^[a-z0-9-]*$/.test(name)) return label.test(name) ? name : null;
|
|
71
|
+
const ascii = domainToASCII(name);
|
|
72
|
+
return label.test(ascii) ? ascii : null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// An exact domain in its DNS form: a Unicode domain becomes its punycode form; anything else returns null.
|
|
76
|
+
export function asciiDomain(input) {
|
|
77
|
+
if (typeof input !== 'string') return null;
|
|
78
|
+
const value = input.normalize('NFC').toLowerCase();
|
|
79
|
+
if (!/^[\p{L}\p{N}\p{M}.-]+$/u.test(value)) return null;
|
|
80
|
+
return /^[\x00-\x7f]+$/.test(value) ? value : domainToASCII(value) || null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The Unicode spelling of an ASCII label or domain, or null when it has no punycode part.
|
|
84
|
+
export function unicodeName(value) {
|
|
85
|
+
if (typeof value !== 'string' || !/(?:^|\.)xn--/.test(value)) return null;
|
|
86
|
+
const shown = domainToUnicode(value);
|
|
87
|
+
return shown && shown !== value ? shown : null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// A Latin-letter key for name matching in rival, app, mark and handle sources: Grønnstue -> gronnstue.
|
|
91
|
+
// ASCII names keep their DNS label as the key.
|
|
92
|
+
export function searchKey(input) {
|
|
93
|
+
const dns = normalizeName(input);
|
|
94
|
+
if (!dns?.startsWith('xn--')) return dns;
|
|
95
|
+
const key = foldLatin(input).replace(/[^a-z0-9-]/g, '');
|
|
96
|
+
return label.test(key) ? key : dns;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Short labels (four characters or fewer, counted in Unicode) are often premium at the registry or the shop.
|
|
100
|
+
// Their list price is withheld until a shop quote settles it.
|
|
101
|
+
export const premiumRiskLength = 4;
|
|
102
|
+
export function premiumRisk(domain) {
|
|
103
|
+
const first = String(domain ?? '').split('.')[0];
|
|
104
|
+
if (!first) return false;
|
|
105
|
+
return [...(unicodeName(first) ?? first)].length <= premiumRiskLength;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// A free row for a short label: the registry says free, but the price may be premium. No list price stays on it.
|
|
109
|
+
export function withPremiumRisk(row) {
|
|
110
|
+
if (!row || row.status !== 'probably-free' || !premiumRisk(row.domain)) {
|
|
111
|
+
if (row?.status === 'check-at-shop' && premiumRisk(row.domain) && row.price != null) {
|
|
112
|
+
return { ...withoutListPrice(row, 'check-at-shop'), premiumRisk: true };
|
|
113
|
+
}
|
|
114
|
+
return row;
|
|
115
|
+
}
|
|
116
|
+
return { ...withoutListPrice(row, 'premium'), premium: 'risk' };
|
|
61
117
|
}
|
|
62
118
|
|
|
63
119
|
export function nameCandidates(name, { variants: includeVariants = true, endings = defaultEndings } = {}) {
|
|
64
120
|
const selected = endings;
|
|
65
121
|
const exact = [...new Set(selected)].map(tld => ({ domain: name + '.' + tld, tld, exact: true }));
|
|
66
|
-
|
|
122
|
+
// A punycode label takes no prefix or suffix: "get" + "xn--..." is not that spelling.
|
|
123
|
+
if (!includeVariants || !selected.includes('com') || name.startsWith('xn--')) return exact;
|
|
67
124
|
const variants = ['get' + name, 'try' + name, 'use' + name, name + 'hq'];
|
|
68
125
|
return [...exact, ...variants.filter(value => label.test(value)).map(value => ({
|
|
69
126
|
domain: value + '.com', tld: 'com', exact: false,
|
|
@@ -86,7 +143,7 @@ export function termCosts(tld, price, renewal) {
|
|
|
86
143
|
export function rankName(rows) {
|
|
87
144
|
return rows.map(row => {
|
|
88
145
|
const { tld, exact, status, price = null, renewal = null } = row;
|
|
89
|
-
const reason = status === 'premium' ? 'Premium price' : status === 'reserved' ? 'Not offered for registration'
|
|
146
|
+
const reason = status === 'premium' ? row.premium === 'risk' ? 'May be premium' : 'Premium price' : status === 'reserved' ? 'Not offered for registration'
|
|
90
147
|
: status === 'taken' ? 'Already registered'
|
|
91
148
|
: status === 'check-at-shop' ? 'Check at shop'
|
|
92
149
|
: exact ? 'Exact name' : 'Name variation';
|
|
@@ -98,7 +155,7 @@ export function rankName(rows) {
|
|
|
98
155
|
|
|
99
156
|
export function pickName(rows, eligible) {
|
|
100
157
|
return rows.reduce((best, row) => {
|
|
101
|
-
if (!canRecommend(row.tld, eligible) || !['probably-free', 'confirmed'].includes(row.status)) return best;
|
|
158
|
+
if (!canRecommend(row.tld, eligible) || premiumRisk(row.domain) || !['probably-free', 'confirmed'].includes(row.status)) return best;
|
|
102
159
|
return !best || firstCost(row) < firstCost(best) ||
|
|
103
160
|
(firstCost(row) === firstCost(best) && row.exact && !best.exact) ? row : best;
|
|
104
161
|
}, undefined);
|
|
@@ -150,8 +207,10 @@ export function mergeQuote(row, quote) {
|
|
|
150
207
|
return { ...withoutListPrice(row, 'reserved', quote.reason ?? 'Not offered for registration'),
|
|
151
208
|
checkedAt: quote.checkedAt ?? row.checkedAt };
|
|
152
209
|
}
|
|
210
|
+
// A short name stays a possible premium unless the shop marks its quote as standard.
|
|
153
211
|
const premium = row.status === 'premium' && row.premium === true ? true
|
|
154
|
-
: quote.status === 'premium' ? quote.premium ?? true : possiblePremium(row, quote) ? 'possible'
|
|
212
|
+
: quote.status === 'premium' ? quote.premium ?? true : possiblePremium(row, quote) ? 'possible'
|
|
213
|
+
: (row.premium === 'risk' || row.premiumRisk) && quote.standard !== true ? 'possible' : false;
|
|
155
214
|
const price = money(quote.price) > 0 ? quote.price : null;
|
|
156
215
|
return { ...row, status: premium ? 'premium' : quote.status, price, renewal: price == null ? null : quote.renewal ?? null,
|
|
157
216
|
...(premium && { premium }), shop: quote.shopName, buyUrl: quote.buyUrl, priceCheckedAt: null, priceSource: null,
|
|
@@ -175,7 +234,8 @@ export async function searchCandidates(groups, options = {}) {
|
|
|
175
234
|
const onResult = ({ domain, tld, exact }, registry) => {
|
|
176
235
|
if (timeLeft() <= 0) return;
|
|
177
236
|
lookedUp.set(domain, registry);
|
|
178
|
-
|
|
237
|
+
const status = registrationStatus(registry);
|
|
238
|
+
options.onProgress?.({ domain, status: status === 'probably-free' && premiumRisk(domain) ? 'premium' : status });
|
|
179
239
|
if (registry.status !== 'taken' || !exact || !siteEndings.includes(tld)) return;
|
|
180
240
|
const timeout = Math.min(options.siteTimeout ?? 1200, timeLeft());
|
|
181
241
|
sites.set(domain, { pending: (options.comSite ?? checkDomainSite)(domain, timeout, options.siteDetails).then(site => {
|
|
@@ -204,8 +264,8 @@ export async function searchCandidates(groups, options = {}) {
|
|
|
204
264
|
const rows = rankName(group.candidates.map(row => {
|
|
205
265
|
const lookup = lookedUp.get(row.domain);
|
|
206
266
|
if (!lookup) {
|
|
207
|
-
const waiting = { ...row, status: 'check-at-shop', registryReason: 'Registry lookup timed out',
|
|
208
|
-
...listQuote(catalog, row, now, bundled) };
|
|
267
|
+
const waiting = withPremiumRisk({ ...row, status: 'check-at-shop', registryReason: 'Registry lookup timed out',
|
|
268
|
+
...listQuote(catalog, row, now, bundled) });
|
|
209
269
|
const signal = signals.get(row.domain);
|
|
210
270
|
return ['premium', 'reserved'].includes(signal?.status) ? mergeQuote(waiting, signal) : waiting;
|
|
211
271
|
}
|
|
@@ -215,9 +275,10 @@ export async function searchCandidates(groups, options = {}) {
|
|
|
215
275
|
? { shop: quote.shop, checkedAt: quote.priceCheckedAt, ...termCosts(row.tld, quote.price, quote.renewal),
|
|
216
276
|
renewalJump: quote.renewal > 2 * quote.price }
|
|
217
277
|
: null;
|
|
218
|
-
const settled = { ...row, status, checkedAt: lookup.checkedAt ?? checkedAt, source: lookup.source,
|
|
219
|
-
forSale: Boolean(lookup.forSale), ...(lookup.marketplace && { marketplace: lookup.marketplace }),
|
|
220
|
-
...(status
|
|
278
|
+
const settled = withPremiumRisk({ ...row, status, checkedAt: lookup.checkedAt ?? checkedAt, source: lookup.source,
|
|
279
|
+
registryReason: lookup.reason, forSale: Boolean(lookup.forSale), ...(lookup.marketplace && { marketplace: lookup.marketplace }),
|
|
280
|
+
...(status === 'check-at-shop' && lookup.likely && { likely: lookup.likely }),
|
|
281
|
+
...(status !== 'taken' ? quote : listPrice && { listPrice }) });
|
|
221
282
|
if (status === 'premium') return { ...withoutListPrice(settled, 'premium'), premium: true };
|
|
222
283
|
if (status === 'reserved') return withoutListPrice(settled, 'reserved', lookup.reason);
|
|
223
284
|
const signal = status === 'taken' ? null : signals.get(row.domain);
|