Skip to content

Missing trailing backslash after pathBase when Path is empty #53177

Open
@rbans96

Description

@rbans96

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Found a bug that backslash is missing after PathBase, if Path is empty.

Expected Behavior

If pathBase is non empty and Path is empty, then add a trailing backslash after pathBase in the route url.

Actual url: /twci369916wu2hsws-twci369916wu2hsws.fhir.mshapis.com?_type=Patient&_count=500&ct=er97f5lRTbShgbGOqaGBuaGFqbGJiZmhibmRobGZUSwAAAD%2F%2Fw%3D%3D

Expected url: /twci369916wu2hsws-twci369916wu2hsws.fhir.mshapis.com/?_type=Patient&_count=500&ct=er97f5lRTbShgbGOqaGBuaGFqbGJiZmhibmRobGZUSwAAAD%2F%2Fw%3D%3D

The issue is here

string combinePath = (pathBase.HasValue || path.HasValue) ? (pathBase + path).ToString() : "/";

Steps To Reproduce

  • Search URl: https://localhost:44349/twci369916wu2hsws-twci369916wu2hsws.fhir.mshapis.com/?_type=Patient&_count=500
    _Host: localhost:44349, basePath: /twci369916wu2hsws-twci369916wu2hsws.fhir.mshapis.com, Path: Empty, Query parameter: type=Patient&count=500
  • In our implementation, we are calling AspnetCore UrlHelper.RouteUrl() to get the route url
  • Further debugging, LinkGeneratorExtensions.GetPathByRouteValues -> GetPathByAddress() -> DefaultLinkGenerator.GetPathByEndpoints() -> TryProcessTemplate() fetches pathBase as ""/twci369916wu2hsws-twci369916wu2hsws.fhir.mshapis.com" and Path as ""(empty)
  • UriHelper.BuildRelative constructs the url as below
    /twci369916wu2hsws-twci369916wu2hsws.fhir.mshapis.com?_type=Patient&_count=500&ct=er97f5lRTbShgbGOqaGBuaGFqbGJiZmhibmRobGZUSwAAAD%2F%2Fw%3D%3D

Expected url: /twci369916wu2hsws-twci369916wu2hsws.fhir.mshapis.com/?_type=Patient&_count=500&ct=er97f5lRTbShgbGOqaGBuaGFqbGJiZmhibmRobGZUSwAAAD%2F%2Fw%3D%3D

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions