parse-domain icon indicating copy to clipboard operation
parse-domain copied to clipboard

Leading dots lead to INVALID even with lax validation e.g .reflectoring.io

Open paradoxloop opened this issue 1 year ago • 0 comments

Thank you for great library. We use the library in both strict and lax mode depending on how flexible we want to be with the user input. One of the things that repeatly trips users up is they paste the domain with a leading dot having removed the subdomains but accidentally left the dot. Not sure if this is something the librar is meant to accept as valid input under lax.

const parseResult = parseDomain(fromUrl(".reflectoring.io"), { validation: Validation.Lax, }); console.log(parseResult);

Current Result: { type: 'INVALID', hostname: '.reflectoring.io', errors: [ { type: 'LABEL_MIN_LENGTH', message: 'Label "" is too short. Label is 0 octets long but should be at least 1.', column: 1 } ] }

Expected Result: { type: 'LISTED', hostname: 'reflectoring.io', labels: [ 'reflectoring', 'io' ], icann: { subDomains: [], domain: 'reflectoring', topLevelDomains: [ 'io' ] }, subDomains: [], domain: 'reflectoring', topLevelDomains: [ 'io' ] }

paradoxloop avatar Mar 26 '24 09:03 paradoxloop