فهرست منبع

render page.path in PageTimeline

Yuki Takei 6 سال پیش
والد
کامیت
a41803edb8
2فایلهای تغییر یافته به همراه14 افزوده شده و 1 حذف شده
  1. 10 1
      src/client/js/components/PageTimeline.jsx
  2. 4 0
      src/server/util/swigFunctions.js

+ 10 - 1
src/client/js/components/PageTimeline.jsx

@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
 
 import { withTranslation } from 'react-i18next';
 
+import * as entities from 'entities';
+
 import AppContainer from '../services/AppContainer';
 import { createSubscribedElement } from './UnstatedUtils';
 
@@ -75,7 +77,14 @@ class PageTimeline extends React.Component {
       return;
     }
 
-    return JSON.parse(pageIdsElm.text);
+    let pages = JSON.parse(pageIdsElm.text);
+    // decode path
+    pages = pages.map((page) => {
+      page.path = decodeURIComponent(entities.decodeHTML(page.path));
+      return page;
+    });
+
+    return pages;
   }
 
   render() {

+ 4 - 0
src/server/util/swigFunctions.js

@@ -1,7 +1,10 @@
 module.exports = function(crowi, app, req, locals) {
   const debug = require('debug')('growi:lib:swigFunctions');
   const stringWidth = require('string-width');
+  const entities = require('entities');
+
   const { pathUtils } = require('growi-commons');
+
   const Page = crowi.model('Page');
   const User = crowi.model('User');
   const {
@@ -178,6 +181,7 @@ module.exports = function(crowi, app, req, locals) {
     return pages.map((page) => {
       return {
         id: page.id,
+        path: entities.encodeHTML(page.path),
         revision: page.revision,
       };
     });