WithTrailingSlash on url puts / after querystring

Maybe it is how WithTrailingSlash is to work? There might be scenarios outside of urls where it is being used. If not and it’s only to be used with urls then maybe it needs to be updated.

I noticed that if there is a querystring in the url it puts a slash after the querystring. e.g. /my-page?qs=123/

I would think the correct way would be to put it before the ?. e.g. /my-page/?qs=123

public static string WithTrailingSlash(this string path)
    if (String.IsNullOrEmpty(path))
        throw new ArgumentNullException("path");

    if (path[path.Length - 1] != '/')
        return path + "/";
    return path;

It doesn’t work on queryStrings, you can use it before adding the queryString. I’ve no intentions of making it more complicated to handle a niche use-case where it isn’t clear what the expected behavior would be. You’ll need to create your own if you want that behavior.

Yep. We already did. We’re caught off guard at first time it happened.

We were doing a requestDTO.ToGetUrl() and the request DTO happened to have other props/params not in the url path, so it added them as querystings and then in this instance called .WithTrailingSlash() and it added after the request params.

We have no issues keeping it the same.

Out of curiosity, do you have an estimated date or month for your next release? 5.4.2?

The latest version is already on MyGet as normal, the next release on NuGet will be v5.5 and will be in March. Hoping for mid March but not committing.