diff --git a/backend/tests/Squidex.Web.Tests/UrlDecodeRouteParamsAttributeTests.cs b/backend/tests/Squidex.Web.Tests/UrlDecodeRouteParamsAttributeTests.cs new file mode 100644 index 000000000..a0c17e3ee --- /dev/null +++ b/backend/tests/Squidex.Web.Tests/UrlDecodeRouteParamsAttributeTests.cs @@ -0,0 +1,40 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Routing; +using Xunit; + +namespace Squidex.Web +{ + public class UrlDecodeRouteParamsAttributeTests + { + [Fact] + public void Should_url_decode_params() + { + var sut = new UrlDecodeRouteParamsAttribute(); + + var actionContext = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor + { + FilterDescriptors = new List() + }); + + var actionExecutingContext = new ActionExecutingContext(actionContext, new List(), new Dictionary + { + ["key"] = "path%2Fto%2Fsomething" + }, null!); + + sut.OnActionExecuting(actionExecutingContext); + + Assert.Equal("path/to/something", actionExecutingContext.ActionArguments["key"]); + } + } +}