Files
Umbraco-CMS/src/Umbraco.Cms.Api.Management/Controllers/FileSystemManagementControllerBase.cs
Kenn Jacobsen e4f9f98f2d File system endpoints redo (#15521)
* First stab at a massive remake of file system based endpoints

* Do not prefix system paths with directory separator char

* Ensure correct and consistent response types

* Fix partial view snippets endpoints

* Clean up IO (path) operations

* Update OpenAPI JSON to match new endpoints

* Return 201 when renaming file system resources

* Add "IsFolder" to file system item endpoints

* Replace "parentPath" with a "parent" object for file system creation endpoints

* Update OpenAPI JSON

* Rewrite snippets

* Regenerate OpenAPI JSON after forward merge

* Remove stylesheet overview endpoint

* Regenerate OpenAPI JSON after forward merge

* add server-file-system module to importmap

* Expose generated resource identifier in 201 responses

---------

Co-authored-by: Mads Rasmussen <madsr@hey.com>
2024-01-22 08:20:45 +01:00

22 lines
862 B
C#

using System.Net;
namespace Umbraco.Cms.Api.Management.Controllers;
public abstract class FileSystemManagementControllerBase : ManagementApiControllerBase
{
protected string DecodePath(string path)
{
// OpenAPI does not allow reserved chars as "in:path" parameters, so clients based on the Swagger JSON will URL
// encode the path. Normally, ASP.NET Core handles that encoding with an automatic decoding - apparently just not
// for forward slashes, for whatever reason... so we need to deal with those. Hopefully this will be addressed in
// an upcoming version of ASP.NET Core.
// See also https://github.com/dotnet/aspnetcore/issues/11544
if (path.Contains("%2F", StringComparison.OrdinalIgnoreCase))
{
path = WebUtility.UrlDecode(path);
}
return path;
}
}