Skip to content

fix(req): ignore trailing dot in subdomains#7341

Closed
andrewkernel wants to merge 1 commit into
expressjs:masterfrom
andrewkernel:fix-subdomains-fqdn-trailing-dot
Closed

fix(req): ignore trailing dot in subdomains#7341
andrewkernel wants to merge 1 commit into
expressjs:masterfrom
andrewkernel:fix-subdomains-fqdn-trailing-dot

Conversation

@andrewkernel

Copy link
Copy Markdown

Summary

This fixes req.subdomains for fully qualified domain names that include a trailing dot. The trailing root label is now ignored before applying the configured subdomain offset, so tobi.ferrets.example.com. behaves the same as tobi.ferrets.example.com.

Why

Before this change, the trailing dot was treated as an empty DNS label. With the default subdomain offset, that shifted the result and returned ['example', 'ferrets', 'tobi'] instead of ['ferrets', 'tobi'].

Changes

  • strip a single trailing dot inside the req.subdomains getter before splitting labels
  • add a regression test for fully qualified domain names
  • add an unreleased bug-fix note

Tests

  • npx mocha --require test/support/env --reporter spec --check-leaks test/req.subdomains.js
  • npm test
  • npm run lint
  • git diff --check HEAD~1..HEAD

@krzysdz

krzysdz commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Duplicate of #7331

@krzysdz krzysdz marked this as a duplicate of #7331 Jun 30, 2026
@krzysdz krzysdz closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants