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

Uri.TryCreate returns different results on Windows and Linux #76816

Closed
WernerMairl opened this issue Oct 10, 2022 · 4 comments
Closed

Uri.TryCreate returns different results on Windows and Linux #76816

WernerMairl opened this issue Oct 10, 2022 · 4 comments
Milestone

Comments

@WernerMairl
Copy link
Contributor

WernerMairl commented Oct 10, 2022

Description

It seems that the following call returns different results on Windows (current .Net 6 SDK on Windows 11 Desktop, latest Visual Studio) and Linux (Github Action with current .Net 6 SDK, ubuntu-latest, dotnet-version 6.0.x)!
Not testet with .Net 7 RCx!

Uri.TryCreate("/vendor.test.js",Urikind.Absolute, out var result)

On Windows the TryCreate function returns bool.false
On my CI Server (Github current Ubuntu) it returns true, and the outcoming Uri from type "file://"

No time for deeper investigations at this moment, but I hope that helps....

BR
Werner

Reproduction Steps

Uri.TryCreate("/vendor.test.js",Urikind.Absolute, out var result)

Expected behavior

whatever it comes out: ist should be the same on Windows and Linux

Actual behavior

Different results between Windows and Linux

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 10, 2022
@ghost
Copy link

ghost commented Oct 10, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

It seems that the following call returns different results on Windows (current .Net 6 SDK on Windows 11 Desktop, latest Visual Studio) and Linux (Github Action with current .Net 6 SDK, ubuntu-latest, dotnet-version 6.0.x)!
Not testet with .Net 7 RCx!

Uri.TryCreate("/vendor.test.js",Urikind.Absolute, out var result)
On Windows the TryCreate function returns bool.false
On my CI Server (Github current Ubuntu) it returns true, and the outcoming Uri from type "file://"

No time for deeper investigations at this moment, but I hope that helps....

BR
Werner

Reproduction Steps

Uri.TryCreate("/vendor.test.js",Urikind.Absolute, out var result)

Expected behavior

whatever it comes out: ist should be the same on Windows and Linux

Actual behavior

Different results between Windows and Linux

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: WernerMairl
Assignees: -
Labels:

area-System.Net

Milestone: -

@stephentoub
Copy link
Member

This is by design. For better or worse, Uri supports parsing file paths, and on Linux "/vendor.test.js" is a valid absolute file path.

@WernerMairl
Copy link
Contributor Author

Unexpected but acceptable

Feel free to close the issue

@stephentoub stephentoub closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Oct 10, 2022
@MihaZupan
Copy link
Member

For reference, once #59099 (comment) is implemented, you should be able to avoid this by doing

var options = new UriCreationOptions
{
    UriKind = Urikind.Absolute,
    AllowImplicitFilePaths = false
};

Uri.TryCreate("/vendor.test.js", options, out Uri uri)

@ghost ghost locked as resolved and limited conversation to collaborators Nov 9, 2022
@karelz karelz added this to the 8.0.0 milestone Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants