Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Uri does not compact empty path segments as claimed #45550

Open
spazmodius opened this issue Mar 27, 2025 · 3 comments · May be fixed by #45762
Open

System.Uri does not compact empty path segments as claimed #45550

spazmodius opened this issue Mar 27, 2025 · 3 comments · May be fixed by #45762
Assignees
Labels
dotnet-fundamentals/svc 📌 seQUESTered Identifies that an issue has been imported into Quest. ⌚ Not Triaged Not triaged

Comments

@spazmodius
Copy link

spazmodius commented Mar 27, 2025

Type of issue

Typo

Description

This document claims that

As part of canonicalization in the constructor for some schemes, dot-segments and empty segments (/./, /../, and //) are compacted (in other words, they are removed). The schemes for which System.Uri compacts segments include http, https, ...

It is not true that empty segments are removed.

Page URL

https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-uri

Content source URL

https://github.com/dotnet/docs/blob/main/docs/fundamentals/runtime-libraries/system-uri.md

Document Version Independent Id

ef49fced-bed9-9f02-5e78-a47784652c2c

Platform Id

3984eeb2-f354-0f34-b10a-6b1bf1599142

Article author

@gewarren

Metadata

  • ID: 534fcd22-0904-63de-abc9-46d9ab768b88
  • PlatformId: 3984eeb2-f354-0f34-b10a-6b1bf1599142
  • Service: dotnet-fundamentals

Related Issues


Associated WorkItem - 417520

@adegeo
Copy link
Contributor

adegeo commented Mar 28, 2025

I just tested and it works for me. I tested with .NET Framework 4.8, .NET 8, and .NET 9

using System;

namespace MyApp
{
    public class App
    {
        public static void Main(string[] args)
        {
            string uriPath = "http://myUrl/other/../second/././/./hello";
            
            var uri = new Uri(uriPath);

            Console.WriteLine($"Original URI: {uriPath}");
            Console.WriteLine($"AbsoluteUri: {uri.AbsoluteUri}");
            Console.WriteLine($"PathAndQuery: {uri.PathAndQuery}");
        }
    }
}

Output:

Original URI: http://myUrl/other/../second/././/./hello
AbsoluteUri: http://myurl/second//hello
PathAndQuery: /second//hello

@adegeo adegeo removed the ⌚ Not Triaged Not triaged label Mar 28, 2025
@adegeo
Copy link
Contributor

adegeo commented Mar 28, 2025

I'm going to close this issue. Please feel free to reopen it and add more details.

@adegeo adegeo closed this as completed Mar 28, 2025
@spazmodius
Copy link
Author

Thanks for looking at this, @adegeo . Either I wasn't clear in my issue description, or you didn't fully assess your output, because it validates the issue I meant to describe. Your output still contains un-compacted empty segments.

@gewarren gewarren self-assigned this Apr 3, 2025
@dotnetrepoman dotnetrepoman bot added the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Apr 3, 2025
@gewarren gewarren added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Apr 4, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Apr 4, 2025
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Apr 4, 2025
@gewarren gewarren reopened this Apr 9, 2025
@github-project-automation github-project-automation bot moved this from 🔖 Ready to 🏗 In progress in dotnet/docs April 2025 sprint project Apr 9, 2025
@dotnet-policy-service dotnet-policy-service bot added the ⌚ Not Triaged Not triaged label Apr 9, 2025
@gewarren gewarren linked a pull request Apr 9, 2025 that will close this issue
@gewarren gewarren moved this from 🏗 In progress to 👀 In review in dotnet/docs April 2025 sprint project Apr 9, 2025
@dotnetrepoman dotnetrepoman bot added the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Apr 9, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fundamentals/svc 📌 seQUESTered Identifies that an issue has been imported into Quest. ⌚ Not Triaged Not triaged
Projects
Status: 👀 In review
Development

Successfully merging a pull request may close this issue.

3 participants