pagePathUtil.js 466 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. function encodePagesPath(pages) {
  3. pages.forEach(function(page) {
  4. if (!page.path) {
  5. return;
  6. }
  7. page.path = encodePagePath(page.path);
  8. });
  9. return pages;
  10. }
  11. function encodePagePath(path) {
  12. var paths = path.split('/');
  13. paths.forEach(function(item, index) {
  14. paths[index] = encodeURIComponent(item);
  15. });
  16. return paths.join('/');
  17. }
  18. module.exports = {
  19. encodePagePath: encodePagePath,
  20. encodePagesPath: encodePagesPath
  21. };