Skip to content

Trim whitespace from domain names#41

Merged
loks0n merged 1 commit intomainfrom
feat/trim-names
Apr 18, 2026
Merged

Trim whitespace from domain names#41
loks0n merged 1 commit intomainfrom
feat/trim-names

Conversation

@loks0n
Copy link
Copy Markdown
Contributor

@loks0n loks0n commented Mar 11, 2026

Summary

  • Automatically trim() domain names in Record and Question constructors to strip leading/trailing whitespace
  • Added tests for whitespace, tabs, and newline trimming in both classes

Test plan

  • Unit tests pass (testConstructorTrimsWhitespaceFromName, testConstructorTrimsTabsAndNewlinesFromName, testWithNameTrimsWhitespace)
  • Verify no regressions in existing test suite

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 18, 2026

Greptile Summary

This PR adds trim() around the strtolower() call in the Record and Question constructors, stripping leading/trailing whitespace (including tabs and newlines) from domain names at construction time. The withName() method on Record inherits the fix automatically since it delegates to the constructor. Five new unit tests cover the expected inputs.

Confidence Score: 5/5

Safe to merge — minimal, well-tested change with no side effects on existing paths.

The change is a single-line addition of trim() in two constructors, both thoroughly tested. No logic is altered beyond whitespace normalization, and no regressions are expected.

No files require special attention.

Important Files Changed

Filename Overview
src/DNS/Message/Question.php Wraps the name assignment with trim() so leading/trailing whitespace is stripped before lowercasing — correct and straightforward.
src/DNS/Message/Record.php Same one-line trim() addition as Question; withName() inherits the fix because it delegates to the constructor.
tests/unit/DNS/Message/QuestionTest.php Two new tests cover space trimming and tab/newline trimming in the Question constructor — good coverage of the change.
tests/unit/DNS/Message/RecordTest.php Three new tests cover space trimming, tab/newline trimming in the constructor, and whitespace trimming via withName() — comprehensive for the changed paths.

Reviews (1): Last reviewed commit: "Trim whitespace from domain names in Rec..." | Re-trigger Greptile

@loks0n loks0n merged commit 43006f3 into main Apr 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant