-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3701 from SukkaW/full_url_for
feat(full_url_for): utilize hexo-util module
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
const { full_url_for } = require('hexo-util'); | ||
|
||
module.exports = function(path) { | ||
return full_url_for.call(this, path); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
describe('full_url_for', () => { | ||
const ctx = { | ||
config: { url: 'https://example.com' } | ||
}; | ||
|
||
const fullUrlFor = require('../../../lib/plugins/helper/full_url_for').bind(ctx); | ||
|
||
it('no path input', () => { | ||
fullUrlFor().should.eql(ctx.config.url + '/'); | ||
}); | ||
|
||
it('internal url', () => { | ||
fullUrlFor('index.html').should.eql(ctx.config.url + '/index.html'); | ||
fullUrlFor('/').should.eql(ctx.config.url + '/'); | ||
fullUrlFor('/index.html').should.eql(ctx.config.url + '/index.html'); | ||
}); | ||
|
||
it('external url', () => { | ||
[ | ||
'https://hexo.io/', | ||
'//google.com/' | ||
].forEach(url => { | ||
fullUrlFor(url).should.eql(url); | ||
}); | ||
}); | ||
|
||
it('only hash', () => { | ||
fullUrlFor('#test').should.eql(ctx.config.url + '/#test'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters