Skip to content

fix: safely encode dynamic URL path segments#35

Merged
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
shadrach68:DynamicRoute
Jun 16, 2026
Merged

fix: safely encode dynamic URL path segments#35
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
shadrach68:DynamicRoute

Conversation

@shadrach68

Copy link
Copy Markdown
Contributor

closes #20

Task Summary

Safely encode dynamic URL path segments before they are interpolated into service endpoint paths.

Background / Context

Service methods were building paths with string interpolation, such as /guilds/${guildId}/roles and /guilds/${guildId}/members/${walletAddress}/roles. If a dynamic value contained reserved URL characters (like /, #, or spaces), the request path could become malformed. This PR ensures all dynamic path values are encoded with encodeURIComponent before being inserted into endpoint paths, while keeping query parameter handling separate and preserving existing input validation.

Changes Made

  • Created encodePathSegment helper utility in src/utils/formatting.ts.
  • Updated RolesService and GuildsService to safely encode guildId and walletAddress parameters.
  • Added test coverage in tests/services.test.ts to assert that reserved characters like / and spaces are accurately encoded (e.g. %2F and %20).

Acceptance Criteria Met

  • guildId values used in path segments are URL-encoded
  • walletAddress values used in path segments are URL-encoded
  • Existing endpoints still produce the same path for simple IDs
  • Tests cover at least one ID containing a reserved character such as /, #, or space

Testing Requirements

  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test:run passes — new behaviour has test coverage
  • pnpm build succeeds

Semver Impact

Patch

@Lakes41 Lakes41 merged commit d86e943 into Adamantine-guild:main Jun 16, 2026
1 check failed
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.

Encode dynamic route parameters in service paths

2 participants