Geeksltd / Olive

Olive framework, for more productive cross platform .NET solutions. It's available under the GPL v3 license. See License.md for more information.
https://geeksltd.github.io/Olive
Other
44 stars 44 forks source link

MenuItem.MatchesCurrentUrl() returns false due to comparing encoded urls with decoded urls #271

Closed j-lustig closed 5 years ago

j-lustig commented 5 years ago

https://github.com/Geeksltd/Olive/blob/e83d06b3d64e6dbfeb2c417bdac86f547fc89402/Olive.Mvc/Utilities/MenuItem.cs#L15-L19

When checking the active item for a a menu we check it matches the current url, the url is in the format admin/project/2019%20a1/project-brief. This is because 2019 a1 is the project number and gets encoded when used in the url.

When using Url.Index to create the url it is not yet encoded. This is then used to compare the url with Context.Current.Request().ToPathAndQuery(); which is encoded. In the example we would end up with admin/project/2019%20a1/project-brief (from ToPathAndQuery()) compared with admin/project/2019 a1/project-brief (from Url.Index()) which returns false when it should return true.

If we use UrlDecode() on currentUrl before making the comparison I believe this solves the issue.

hamidmayeli commented 5 years ago

Hi @j-lustig , Thanks for that. It would be available with the next version.