Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export function parseRegistryName(hostname) {
// registry rejects sends a tab to a page saying it does not exist.
const LABEL = /^[a-z0-9]{1,63}$/;
if (!LABEL.test(label) || !LABEL.test(tld)) return null;
// Both halves numeric is refused by the registry — several parsers read a
// two-part dotted number as an abbreviated IPv4 literal, so `1.420` is
// genuinely ambiguous where `blue.420` is not. Accepting it here would send
// a tab to a parking page for a name the registry can never register.
if (/^\d+$/.test(label) && /^\d+$/.test(tld)) return null;
return { label, tld };
}

Expand Down
5 changes: 5 additions & 0 deletions test/resolve.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,9 @@ test("dashes are not part of a Moshpit name", () => {
}
assert.deepEqual(parseRegistryName("california.oranges"), { label: "california", tld: "oranges" });
assert.deepEqual(parseRegistryName("blue.420"), { label: "blue", tld: "420" });
// Both halves numeric is refused by the registry (reads as an abbreviated
// IPv4 literal), so the port refuses it too — otherwise a tab lands on a
// parking page for a name the registry can never register.
assert.equal(parseRegistryName("1.420"), null, "1.420");
assert.equal(parseRegistryName("420.187"), null, "420.187");
});
Loading