File tree Expand file tree Collapse file tree 7 files changed +22
-13
lines changed Expand file tree Collapse file tree 7 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 45
45
"hexo-fs" : " ^2.0.0" ,
46
46
"hexo-i18n" : " ^1.0.0" ,
47
47
"hexo-log" : " ^1.0.0" ,
48
- "hexo-util" : " ^1.4 .0" ,
48
+ "hexo-util" : " ^1.5 .0" ,
49
49
"js-yaml" : " ^3.12.0" ,
50
50
"lodash" : " ^4.17.11" ,
51
51
"micromatch" : " ^4.0.2" ,
Original file line number Diff line number Diff line change 2
2
3
3
const moment = require ( 'moment' ) ;
4
4
const cheerio = require ( 'cheerio' ) ;
5
+ const { encodeURL } = require ( 'hexo-util' ) ;
5
6
6
7
describe ( 'open_graph' , ( ) => {
7
8
const Hexo = require ( '../../../lib/hexo' ) ;
@@ -141,7 +142,7 @@ describe('open_graph', () => {
141
142
142
143
const result = openGraph . call ( ctx ) ;
143
144
144
- result . should . contain ( meta ( { property : 'og:url' , content : 'https://xn--fo-9ja.com/b%C3%A1r' } ) ) ;
145
+ result . should . contain ( meta ( { property : 'og:url' , content : encodeURL ( ctx . url ) } ) ) ;
145
146
} ) ;
146
147
147
148
it ( 'images - content' , ( ) => {
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const Promise = require('bluebird');
6
6
const sinon = require ( 'sinon' ) ;
7
7
const sep = pathFn . sep ;
8
8
const testUtil = require ( '../../util' ) ;
9
+ const { full_url_for } = require ( 'hexo-util' ) ;
9
10
10
11
describe ( 'Hexo' , ( ) => {
11
12
const base_dir = pathFn . join ( __dirname , 'hexo_test' ) ;
@@ -427,17 +428,18 @@ describe('Hexo', () => {
427
428
} ) ;
428
429
429
430
it ( '_generate() - should encode url' , ( ) => {
431
+ const path = 'bár' ;
430
432
hexo . config . url = 'http://fôo.com' ;
431
433
432
434
hexo . theme . setView ( 'test.swig' , '{{ url }}' ) ;
433
435
434
436
hexo . extend . generator . register ( 'test' , ( ) => ( {
435
- path : 'bár' ,
437
+ path,
436
438
layout : 'test'
437
439
} ) ) ;
438
440
439
- return hexo . _generate ( ) . then ( ( ) => checkStream ( route . get ( 'bár' ) ,
440
- 'http://xn--fo-8ja.com/b%C3%A1r' ) ) ;
441
+ return hexo . _generate ( ) . then ( ( ) => checkStream ( route . get ( path ) ,
442
+ full_url_for . call ( hexo , path ) ) ) ;
441
443
} ) ;
442
444
443
445
it ( '_generate() - do nothing if it\'s generating' , ( ) => {
Original file line number Diff line number Diff line change 2
2
3
3
const sinon = require ( 'sinon' ) ;
4
4
const Promise = require ( 'bluebird' ) ;
5
+ const { full_url_for } = require ( 'hexo-util' ) ;
5
6
6
7
describe ( 'Category' , ( ) => {
7
8
const Hexo = require ( '../../../lib/hexo' ) ;
@@ -118,9 +119,9 @@ describe('Category', () => {
118
119
it ( 'permalink - should be encoded' , ( ) => {
119
120
hexo . config . url = 'http://fôo.com' ;
120
121
return Category . insert ( {
121
- name : 'bár '
122
+ name : '字 '
122
123
} ) . then ( data => {
123
- data . permalink . should . eql ( 'http://xn--fo-8ja.com/' + data . path ) ;
124
+ data . permalink . should . eql ( full_url_for . call ( hexo , data . path ) ) ;
124
125
hexo . config . url = 'http://yoursite.com' ;
125
126
return Category . removeById ( data . _id ) ;
126
127
} ) ;
Original file line number Diff line number Diff line change 2
2
3
3
const sinon = require ( 'sinon' ) ;
4
4
const pathFn = require ( 'path' ) ;
5
+ const { full_url_for } = require ( 'hexo-util' ) ;
5
6
6
7
describe ( 'Page' , ( ) => {
7
8
const Hexo = require ( '../../../lib/hexo' ) ;
@@ -74,11 +75,12 @@ describe('Page', () => {
74
75
75
76
it ( 'permalink - should be encoded' , ( ) => {
76
77
hexo . config . url = 'http://fôo.com' ;
78
+ const path = 'bár' ;
77
79
return Page . insert ( {
78
80
source : 'foo' ,
79
- path : 'bár'
81
+ path
80
82
} ) . then ( data => {
81
- data . permalink . should . eql ( 'http://xn--fo-8ja.com/b%C3%A1r' ) ;
83
+ data . permalink . should . eql ( full_url_for . call ( hexo , data . path ) ) ;
82
84
hexo . config . url = 'http://yoursite.com' ;
83
85
return Page . removeById ( data . _id ) ;
84
86
} ) ;
Original file line number Diff line number Diff line change 3
3
const sinon = require ( 'sinon' ) ;
4
4
const pathFn = require ( 'path' ) ;
5
5
const Promise = require ( 'bluebird' ) ;
6
+ const { full_url_for } = require ( 'hexo-util' ) ;
6
7
7
8
describe ( 'Post' , ( ) => {
8
9
const Hexo = require ( '../../../lib/hexo' ) ;
@@ -85,12 +86,13 @@ describe('Post', () => {
85
86
} ) ;
86
87
87
88
it ( 'permalink - should be encoded' , ( ) => {
89
+ const slug = 'bár' ;
88
90
hexo . config . url = 'http://fôo.com' ;
89
91
return Post . insert ( {
90
92
source : 'foo.md' ,
91
- slug : 'bár'
93
+ slug
92
94
} ) . then ( data => {
93
- data . permalink . should . eql ( 'http://xn--fo-8ja.com/b%C3%A1r' ) ;
95
+ data . permalink . should . eql ( full_url_for . call ( hexo , slug ) ) ;
94
96
hexo . config . url = 'http://yoursite.com' ;
95
97
return Post . removeById ( data . _id ) ;
96
98
} ) ;
Original file line number Diff line number Diff line change 2
2
3
3
const sinon = require ( 'sinon' ) ;
4
4
const Promise = require ( 'bluebird' ) ;
5
+ const { full_url_for } = require ( 'hexo-util' ) ;
5
6
6
7
describe ( 'Tag' , ( ) => {
7
8
const Hexo = require ( '../../../lib/hexo' ) ;
@@ -103,9 +104,9 @@ describe('Tag', () => {
103
104
it ( 'permalink - should be encoded' , ( ) => {
104
105
hexo . config . url = 'http://fôo.com' ;
105
106
return Tag . insert ( {
106
- name : 'bár '
107
+ name : '字 '
107
108
} ) . then ( data => {
108
- data . permalink . should . eql ( 'http://xn--fo-8ja.com/' + data . path ) ;
109
+ data . permalink . should . eql ( full_url_for . call ( hexo , data . path ) ) ;
109
110
hexo . config . url = 'http://yoursite.com' ;
110
111
return Tag . removeById ( data . _id ) ;
111
112
} ) ;
You can’t perform that action at this time.
0 commit comments