Skip to content

Migrate Country.flag() from deprecated flags.fmcdn.net to flagcdn.com; add overload#1857

Merged
bodiam merged 1 commit into
datafaker-net:mainfrom
spannm:fix/country-flag-cdn-migration
Jun 25, 2026
Merged

Migrate Country.flag() from deprecated flags.fmcdn.net to flagcdn.com; add overload#1857
bodiam merged 1 commit into
datafaker-net:mainfrom
spannm:fix/country-flag-cdn-migration

Conversation

@spannm

@spannm spannm commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Motivation

flags.fmcdn.net is deprecated. The domain operator explicitly requests migrating to flagcdn.com:

Flags.fmcdn.net was CDN of country flags for Flagpedia.net. If you use this domain for embedding flags to your own website, please make the change from flags.fmcdn.net to flagcdn.com that we created exactly for this purpose.

Changes

Country.java

  • Replace deprecated flags.fmcdn.net base URL with https://flagcdn.com/
  • Replace instance field flagUrl by static final FLAG_BASE_URL
  • Add ImageFormat enum (JPG, PNG, SVG, WEBP)
  • Add overload flag(String size, ImageFormat format) for full control over image size and format

CountryTest.java

  • Update testFlag() regex to match the new URL pattern
  • Add testFlagWithSizeProducesValidUrl (@ValueSource) to verify URL structure for a number of sample sizes
  • Add testFlagWithFormatProducesValidUrl (@EnumSource) - covers all ImageFormat values

Backward Compatibility

flag() without arguments keeps the same behavior as before (PNG, width 580px).
Only the CDN domain changes, so existing usages are unaffected.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.52%. Comparing base (ce0f7cf) to head (fb522f1).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1857      +/-   ##
============================================
+ Coverage     92.41%   92.52%   +0.11%     
- Complexity     3555     3561       +6     
============================================
  Files           345      345              
  Lines          7025     7037      +12     
  Branches        685      686       +1     
============================================
+ Hits           6492     6511      +19     
+ Misses          367      364       -3     
+ Partials        166      162       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

…n.com

- add ImageFormat enum (PNG, WEBP, SVG, JPG)
- add flag(String size, ImageFormat format) overload for full control
  over image size and format (fixed-width, fixed-height, icon, SVG)
- replace instance field flagUrl with static final FLAG_BASE_URL
- existing flag() behaviour unchanged (PNG, w580)
@bodiam

bodiam commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Thanks @spannm !

@bodiam bodiam merged commit e0edb64 into datafaker-net:main Jun 25, 2026
17 checks passed
@spannm spannm deleted the fix/country-flag-cdn-migration branch June 25, 2026 15:23
@asolntsev asolntsev added this to the 3.0.0 milestone Jun 25, 2026
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.

5 participants