Skip to content

feat: only generate IANA example domains#3967

Open
hazrid93 wants to merge 1 commit into
faker-js:nextfrom
hazrid93:hazrid93/99_2228
Open

feat: only generate IANA example domains#3967
hazrid93 wants to merge 1 commit into
faker-js:nextfrom
hazrid93:hazrid93/99_2228

Conversation

@hazrid93

Copy link
Copy Markdown

Closes #2228.

Add an optional { allowOnlyExamples?: boolean }: when true, returns .example.<com|org|net>: a 3 label subdomain under the IANA reserved example domains (RFC 2606), which never resolve. Default (no option / false) behavior is unchanged.

@hazrid93
hazrid93 requested a review from a team as a code owner July 20, 2026 10:45
@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a6d3a03
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6a5e1ec2d293c300088e0e67
😎 Deploy Preview https://deploy-preview-3967.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@ST-DDT ST-DDT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing. Please run pnpn run preflight before commiting.

@ST-DDT
ST-DDT marked this pull request as draft July 20, 2026 12:45
Closes faker-js#2228.

Add an optional `{ allowOnlyExamples?: boolean }`: when true, returns <word>.example.<com|org|net>: a 3 label subdomain under the IANA reserved example domains (RFC 2606), which never resolve. Default (no option / false) behavior is unchanged.
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.91%. Comparing base (9ce88ce) to head (a6d3a03).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3967   +/-   ##
=======================================
  Coverage   98.91%   98.91%           
=======================================
  Files         923      924    +1     
  Lines        3223     3228    +5     
  Branches      567      586   +19     
=======================================
+ Hits         3188     3193    +5     
  Misses         31       31           
  Partials        4        4           
Files with missing lines Coverage Δ
src/modules/internet/module.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ST-DDT ST-DDT added c: feature Request for new feature p: 1-normal Nothing urgent s: pending triage Pending Triage m: internet Something is referring to the internet module labels Jul 20, 2026
@ST-DDT
ST-DDT marked this pull request as ready for review July 20, 2026 13:40
@ST-DDT
ST-DDT requested a review from Copilot July 20, 2026 13:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an opt-in way to generate domain names under IANA-reserved “example” domains to reduce the chance of producing domains that might be mistaken for real sites, addressing #2228.

Changes:

  • Extend internet.domainName() with an optional { allowOnlyExamples?: boolean } parameter that produces <word>.example.<com|org|net> when enabled.
  • Update seeded internet module tests to cover both the default domainName() call and the new option.
  • Refresh snapshots to reflect the new test structure and the example-domain output.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/modules/internet.spec.ts Adds a dedicated domainName test group to exercise the new option.
test/modules/snapshots/internet.spec.ts.snap Updates snapshot keys/values for the new domainName cases.
src/modules/internet/module.ts Implements allowOnlyExamples behavior and documents the new option.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +543 to +545
* @param options The optional options object.
* @param options.allowOnlyExamples When `true`, generate a domain under the IANA-reserved example domains (example.com / example.org / example.net) so the result never resolves to a real host. See issue #2228.
*
Comment on lines +553 to +555
/**
* When `true`, generate a domain under the IANA-reserved example domains (example.com / example.org / example.net) so the result never resolves to a real host.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: feature Request for new feature m: internet Something is referring to the internet module p: 1-normal Nothing urgent s: pending triage Pending Triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support only generating IANA example domains

3 participants