frappe / wiki

Free and Open Source Wiki built on top of Frappe
https://frappe.io/wiki
MIT License
241 stars 198 forks source link

Fix route with unicode characters not match URI path #125

Closed hatuan195 closed 1 year ago

BreadGenie commented 1 year ago

Can you give more context on the PR?

hatuan195 commented 1 year ago

Can you give more context on the PR?

We use Vietnamese for the wiki page name, title and route which is UTF8 encoded, like follows: image

When the page is edited the sidebars function does not run correctly.

Reason: in wiki.js The script trying to compare the encoded URI (not in unicode) with the route (which is unicode) and failed:

   activate_sidebars() {
    $(".sidebar-item").each(function (index) {
      const active_class = "active";
      let page_href = window.location.pathname;
      if (page_href.indexOf("#") !== -1) {
        page_href = page_href.slice(0, page_href.indexOf("#"));
      }
      if (
        page_href.split("/").slice(0, -1).join("/") == $(this).data("route")

The solution: Add decodeURIComponent to the pathname, so that it converted to unicode before compare let page_href = decodeURIComponent(window.location.pathname); Same problem for the wiki-edit.js and the show.html script.

The PR is to add decodeURIComponent to the paths in those files

cypress[bot] commented 1 year ago

Passing run #32 ↗︎

0 5 0 0 Flakiness 0

Details:

Merge a6f4ef46240e7a5fb6508d347cfe9f17c09af444 into 32802da442a23f93432fc0fe8701...
Project: Wiki Commit: e6d667e06f ℹ️
Status: Passed Duration: 00:42 💡
Started: Mar 17, 2023 4:49 AM Ended: Mar 17, 2023 4:50 AM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.