We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getHostname
validateHostname
parse().hostname
I have encountered an issue where getHostname(url) and parse(url).hostname return different results for the same URL. This inconsistency can lead to unexpected behavior in applications relying on these functions. I suppose this happens, because if only getHostname has been used (https://github.com/remusao/tldts/blob/master/packages/tldts-core/src/factory.ts#L112), it will not apply extra validation (https://github.com/remusao/tldts/blob/master/packages/tldts-core/src/factory.ts#L126) regardless to passed options.
Use the following URL: ___id___.c.mystat-in.net Call getHostname(url) and parse(url).hostname with the URL.
___id___.c.mystat-in.net
const tldts = require('tldts'); const url = '___id___.c.mystat-in.net'; const hostname1 = tldts.getHostname(url); const hostname2 = tldts.getHostname(url, { validateHostname: true }); const hostname3 = tldts.parse(url).hostname; console.log(`getHostname: ${hostname1}`); // Output: ___id___.c.mystat-in.net console.log(`getHostname with validation: ${hostname2}`); // Output: ___id___.c.mystat-in.net console.log(`parse.hostname: ${hostname3}`); // Output: null
Both getHostname(url) and parse(url).hostname should return the same hostname.
getHostname(url) returns: id.c.mystat-in.net parse(url).hostname returns: null
tldts version: 6.1.74 Node.js version: v18.19.1 Operating System: MacOS 12.5
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description:
I have encountered an issue where getHostname(url) and parse(url).hostname return different results for the same URL. This inconsistency can lead to unexpected behavior in applications relying on these functions. I suppose this happens, because if only
getHostname
has been used (https://github.com/remusao/tldts/blob/master/packages/tldts-core/src/factory.ts#L112), it will not apply extra validation (https://github.com/remusao/tldts/blob/master/packages/tldts-core/src/factory.ts#L126) regardless to passed options.Steps to Reproduce:
Use the following URL:
___id___.c.mystat-in.net
Call getHostname(url) and parse(url).hostname with the URL.
Example Code:
Expected Behavior:
Both getHostname(url) and parse(url).hostname should return the same hostname.
Actual Behavior:
getHostname(url) returns: id.c.mystat-in.net
parse(url).hostname returns: null
Environment:
tldts version: 6.1.74
Node.js version: v18.19.1
Operating System: MacOS 12.5
The text was updated successfully, but these errors were encountered: