-
Notifications
You must be signed in to change notification settings - Fork 66
Add HostingEnvironment.MapPath #572
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
Conversation
|
@dotnet-policy-service agree |
|
Looks good @benamada - can you add some tests? |
|
We're getting ready for a 2.0 release that if you can get that in the next couple days, it'll probably make it in |
…MapPath() output to include/exclude a trailing slash based on whether the input has a trailing slash.
…ccount for possible null input and to match the nullable HttpServerUtility.MapPath path parameter.
|
@twsouthwick I added a new While testing, I discovered there's a small glitch with the original Glad to hear this update has a chance to make the 2.0 release. If there's anything else you'd like to see, just let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thanks for the contribution
test/Microsoft.AspNetCore.SystemWebAdapters.Tests/HttpServerUtilityTests.cs
Show resolved
Hide resolved
|
@twsouthwick good point, I added new tests in I initially had these tests in yesterday but they were failing on Linux and macOS. Digging into it further today, the values returned from |
PR Title
Add HostingEnvironment.MapPath
PR Description
This PR adds a
MapPathmethod toHostingEnvironment. It essentially just calls the existingIMapPathUtility.MapPath()method thatHttpServerUtility.MapPathcalls. With the newHostingEnvironment.MapPathmethod, anHttpContextis not required. BeforeIMapPathUtility.MapPath()is called, there's 2 checks to match the inputHostingEnvironment.MapPathaccepts in .NET Framework.HostingEnvironment.MapPathdoesn't accept paths such asfile.txt. In contrast,HttpServerUtility.MapPathdoes accept this. To matchHostingEnvironment.MapPathin .NET Framework, the new code throws an exception.HostingEnvironment.MapPathdoes accept paths that are UNC like, e.g.\\fileor//file, howeverMapPathUtility.MapPath()throws an error. To avoid the error and conform with the behavior in .NET Framework (without modifyingMapPathUtility.MapPath()), the inboundvirtualPathis modified by collapsing multiple leading slashes to a single slash, e.g./file.Addresses #460