Skip to content

Conversation

@pulimsr
Copy link
Contributor

@pulimsr pulimsr commented Jul 30, 2025

… is enabled

Issue #, 3486

Description of changes: Fixed URI methods adding extra trailing slash when s_preservePathSeparators
is true. Trailing slashes are already preserved in path segments, so no
additional slash should be added.

Affects: GetPath(), GetURLEncodedPath(), GetURLEncodedPathRFC3986()

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

}

if (m_pathSegments.empty() || m_pathHasTrailingSlash)
if (m_pathSegments.empty() || (m_pathHasTrailingSlash && !s_preservePathSeparators))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're verrrrrrrry close to the root of the problem, but might not be there yet. so in the original code

if (m_pathSegments.empty() || m_pathHasTrailingSlash) {
   ss << '/';
}

we only add the trailing slash if there are no segments or m_pathHasTrailingSlash is set to true. we only set that variable to true when we add a path. so instead of repeating that logic here, lets move that up to where we actually set m_pathHasTrailingSlash. This is likely because with preserve path we keep the slash, as before when we normalized it we removed it.

so something like

 m_pathHasTrailingSlash = !s_preservePathSeparators && (!segments.empty() && segments.back() == '/');

would likely do the trick

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.

2 participants