You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
req.subdomains splits an IPv6 host that contains dots #7532
Hi! 🙂 req.subdomains splits an IPv6 host that contains dots.
Environment information
Version: express 5.3.0 (4.22.3 gives the same result)
Platform: Darwin 27.0.0
Node.js version: v24.21.0
Any other relevant information: None.
What steps will reproduce the bug?
req.subdomains does not split a host that is an IP address. This works for [::1]. An IPv6 address can also contain dots, for example the IPv4-mapped address [::ffff:127.0.0.1]. req.subdomains splits that host on the dots:
Note: fetch() rewrites the host to [::ffff:7f00:1], so it does not show the bug. curl, http.get() and X-Forwarded-Host (with trust proxy) send the host as written.
What is the expected behavior?
[] for [::ffff:127.0.0.1], the same as for [::1]. With subdomain offset set to 0, the expected value is ["[::ffff:127.0.0.1]"].
What do you see instead?
["0","[::ffff:127"]. With subdomain offset set to 0: ["1]","0","0","[::ffff:127"].
Additional information
req.hostname keeps the brackets of an IPv6 literal. req.subdomains passes that value to net.isIP() in lib/request.js, and isIP('[::ffff:127.0.0.1]') returns 0. The existing [::1] test passes only because that address has no dots.
Activity
docs: link subdomains-ipv6-dotted-host to expressjs/express#7532