Skip to content

[static querystring] Extract URL parsing into a reusable codec - #12088

Open
LitoMore wants to merge 1 commit into
badges:masterfrom
LitoMore:path-parser
Open

[static querystring] Extract URL parsing into a reusable codec#12088
LitoMore wants to merge 1 commit into
badges:masterfrom
LitoMore:path-parser

Conversation

@LitoMore

@LitoMore LitoMore commented Aug 2, 2026

Copy link
Copy Markdown
Member

Extract the static badge URL grammar into a reusable, side-effect-free codec.

This is a useful utility for other self-hosted services to use the same badge path logic. Maybe we can expose this through badge-maker in the future.

And it useful for our OpenAPI doc pages. Then we can break down badgeContent into label, message, and color, which will be more intuitive for users.

Changes

  • Adds parseStaticBadgePath() for parsing static badge paths and optional query strings.
  • Adds formatStaticBadgePath() for generating equivalent static badge URLs.
  • Supports label, message, color, output format, legacy colon syntax, and Shields path escaping.
  • Applies label, color, and legacy colorB query overrides.
  • Preserves other query parameters, including repeated parameters such as link.
  • Moves the route grammar out of StaticBadge so the parser and service share the same definition.
  • Adds an optional parsePath hook to BaseStaticService.
  • Keeps escapeFormat() as a backwards-compatible alias for the extracted decoder.
  • Preserves the existing single URL-decoding behavior.

Color normalization and rendering-specific query behavior remain in the existing badge pipeline.

Compatibility

The existing static badge HTTP route continues to use the same path grammar and query override pipeline. The query-string static badge endpoint (/static/v1) is unchanged.

The formatter only rejects values that cannot be represented by the path grammar unless an appropriate query override is supplied.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 ✨ Thanks for your contribution to Shields, @LitoMore!

Generated by 🚫 dangerJS against 3fe7353

@LitoMore

LitoMore commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

The service test skipped due to a PR description modification.

I've created a PR to try to solve this problem. See:

@PyvesB

PyvesB commented Aug 2, 2026

Copy link
Copy Markdown
Member

@jNullj you should probably take a look at this one. In particular, it will cause conflicts with #11865. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants