peerigon/parse-domain

LABEL_INVALID_CHARACTER for a legitimate URL

peterjoles opened this issue · 2 comments

The following URL cannot be parsed because it has an underscore in the subdomain.

const parseResult = parseDomain(fromUrl("https://stackadapt_public.s3.amazonaws.com/icons/adchoices/adchoices.png"));

https://stackoverflow.com/questions/2180465/can-domain-name-subdomains-have-an-underscore-in-it

jhnns commented

Hi Peter 👋

we talked about this issue in #134

There's a debate whether underscores are valid or not 😁. If you want/need to support it, you can relax the validation:

import { parseDomain, Validation } from "parse-domain";

const parseResult = parseDomain("_jabber._tcp.gmail.com", {
  validation: Validation.Lax,
});

See also https://github.com/peerigon/parse-domain#-export-validation

That's great to know. Thanks for following up. I'll try and relax the validations.