hexo博客(三):中文url报错问题

中文

Posted by LanMiao on 2017-01-15

做sidebar时,发现一些路径不对,需要在最后加“/”,官方默认主题landscape也是在最后加了,大家就不要疑惑了。
还有中文有的时候是乱码,所以你觉得有中文的地方,最好在用encode和decode处理一下。像sidebar中不可避免的会出现中文,如果不处理会有错或者显示结果不如预期,所以这些地方的url我基本都处理过了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
TypeError: The header content contains invalid characters
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:358:11)
at ServerResponse.res.setHeader (/test/hexo/node_modules/connect-auth/node_modules/connect/lib/patch.js:58:22)
at /test/hexo/node_modules/hexo-server/lib/middlewares/route.js:27:11
at call (/test/hexo/node_modules/connect/index.js:239:7)
at next (/test/hexo/node_modules/connect/index.js:183:5)
at /test/hexo/node_modules/hexo-server/lib/middlewares/header.js:9:5
at call (/test/hexo/node_modules/connect/index.js:239:7)
at next (/test/hexo/node_modules/connect/index.js:183:5)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)
at next (/test/hexo/node_modules/connect/index.js:161:14)

发现:

1
2
http://localhost:4000/hexoblog/tags/博客 #不能打开
http://localhost:4000/hexoblog/tags/博客/ #可以打开

一种办法是修改源代码,这个不讲了参考这个人写的这篇文章

这里省事点,那就加上斜杠呗!官方默认主题landscape也是在最后加了,大家就不要费那些劲了。