File tree Expand file tree Collapse file tree 5 files changed +15
-11
lines changed Expand file tree Collapse file tree 5 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ const { resolve } = require ( 'url' ) ;
3
4
const img = require ( './img' ) ;
4
5
const { encodeURL } = require ( 'hexo-util' ) ;
5
6
@@ -19,7 +20,7 @@ module.exports = ctx => {
19
20
for ( let i = 0 ; i < len ; i ++ ) {
20
21
const asset = PostAsset . findOne ( { post : this . _id , slug : args [ i ] } ) ;
21
22
if ( asset ) {
22
- args [ i ] = encodeURL ( '/' + asset . path ) ;
23
+ args [ i ] = encodeURL ( resolve ( '/' , asset . path ) ) ;
23
24
return img ( ctx ) ( args ) ;
24
25
}
25
26
}
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const url = require ( 'url' ) ;
4
3
const { encodeURL, escapeHTML } = require ( 'hexo-util' ) ;
4
+ const { resolve } = require ( 'url' ) ;
5
5
6
6
/**
7
7
* Asset link tag
@@ -29,8 +29,9 @@ module.exports = ctx => {
29
29
let title = args . length ? args . join ( ' ' ) : asset . slug ;
30
30
const attrTitle = escapeHTML ( title ) ;
31
31
if ( escape === 'true' ) title = attrTitle ;
32
- const link = encodeURL ( url_for . call ( ctx , asset . path ) ) ;
33
32
34
- return `<a href="${ url . resolve ( ctx . config . root , asset . path ) } " title="${ attrTitle } ">${ title } </a>` ;
33
+ const link = encodeURL ( resolve ( ctx . config . root , asset . path ) ) ;
34
+
35
+ return `<a href="${ link } " title="${ attrTitle } ">${ title } </a>` ;
35
36
} ;
36
37
} ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const url_for = require ( '../helper/url_for' ) ;
3
+ const { resolve } = require ( 'url' ) ;
4
+ const { encodeURL } = require ( 'hexo-util' ) ;
4
5
5
6
/**
6
7
* Asset path tag
@@ -18,7 +19,7 @@ module.exports = ctx => {
18
19
const asset = PostAsset . findOne ( { post : this . _id , slug} ) ;
19
20
if ( ! asset ) return ;
20
21
21
- const path = url_for . call ( ctx , asset . path ) ;
22
+ const path = encodeURL ( resolve ( ctx . config . root , asset . path ) ) ;
22
23
23
24
return path ;
24
25
} ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const { encodeURL, escapeHTML } = require ( 'hexo-util' ) ;
4
+ const { resolve } = require ( 'url' ) ;
4
5
5
6
/**
6
7
* Post link tag
@@ -28,10 +29,9 @@ module.exports = ctx => {
28
29
let title = args . length ? args . join ( ' ' ) : post . title ;
29
30
const attrTitle = escapeHTML ( title ) ;
30
31
if ( escape === 'true' ) title = attrTitle ;
31
- const title = args . length ? args . join ( ' ' ) : post . title ;
32
32
33
- const link = url_for . call ( ctx , post . path ) ;
33
+ const link = encodeURL ( resolve ( ctx . config . root , post . path ) ) ;
34
34
35
- return `<a href="${ ctx . config . root } ${ post . path } " title="${ attrTitle } ">${ title } </a>` ;
35
+ return `<a href="${ link } " title="${ attrTitle } ">${ title } </a>` ;
36
36
} ;
37
37
} ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const url_for = require ( '../helper/url_for' ) ;
3
+ const { resolve } = require ( 'url' ) ;
4
+ const { encodeURL } = require ( 'hexo-util' ) ;
4
5
5
6
/**
6
7
* Post path tag
@@ -18,7 +19,7 @@ module.exports = ctx => {
18
19
const post = Post . findOne ( { slug} ) ;
19
20
if ( ! post ) return ;
20
21
21
- const link = url_for . call ( ctx , post . path ) ;
22
+ const link = encodeURL ( resolve ( ctx . config . root , post . path ) ) ;
22
23
23
24
return link ;
24
25
} ;
You can’t perform that action at this time.
0 commit comments