1
1
'use strict' ;
2
2
3
- const should = require ( 'chai' ) . should ( ) ; // eslint-disable-line
3
+ require ( 'chai' ) . should ( ) ;
4
4
const Hexo = require ( 'hexo' ) ;
5
5
const nunjucks = require ( 'nunjucks' ) ;
6
6
const env = new nunjucks . Environment ( ) ;
7
7
const pathFn = require ( 'path' ) ;
8
8
const fs = require ( 'fs' ) ;
9
9
const cheerio = require ( 'cheerio' ) ;
10
+ const { encodeURL } = require ( 'hexo-util' ) ;
10
11
11
12
env . addFilter ( 'uriencode' , str => {
12
13
return encodeURI ( str ) ;
@@ -148,7 +149,6 @@ describe('Feed generator', () => {
148
149
const $ = cheerio . load ( result . data ) ;
149
150
150
151
$ ( 'feed>id' ) . text ( ) . should . eql ( valid ) ;
151
- $ ( 'feed>entry>link' ) . attr ( 'href' ) . should . eql ( valid ) ;
152
152
} ;
153
153
154
154
checkURL ( 'http://localhost/' , '/' , 'http://localhost/' ) ;
@@ -170,20 +170,21 @@ describe('Feed generator', () => {
170
170
path : 'atom.xml'
171
171
} ;
172
172
173
- const checkURL = function ( url , root , valid ) {
173
+ const checkURL = function ( url , root ) {
174
174
hexo . config . url = url ;
175
175
hexo . config . root = root ;
176
176
177
177
const result = generator ( locals ) ;
178
178
const $ = cheerio . load ( result . data ) ;
179
179
180
- $ ( 'feed>id' ) . text ( ) . should . eql ( valid ) ;
181
- $ ( 'feed>entry>link' ) . attr ( 'href' ) . should . eql ( valid ) ;
180
+ if ( url [ url . length - 1 ] !== '/' ) url += '/' ;
181
+ const punyIDN = encodeURL ( url ) ;
182
+ $ ( 'feed>id' ) . text ( ) . should . eql ( punyIDN ) ;
182
183
} ;
183
- const IDN = 'http://gôg.com/' ;
184
- checkURL ( IDN , '/' , IDN ) ;
185
184
186
- checkURL ( IDN , 'blo g/' , IDN ) ;
185
+ checkURL ( 'http://gôg.com/' , '/' ) ;
186
+
187
+ checkURL ( 'http://gôg.com/bár' , '/bár/' ) ;
187
188
} ) ;
188
189
189
190
it ( 'Root encoding' , ( ) => {
0 commit comments