mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-06-21 12:11:12 +00:00
Replace deprecated url.parse() with WHATWG URL API (#955)
This commit is contained in:
parent
b90614fba4
commit
8aa84d79f9
@ -2,15 +2,19 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { parse } = require('url');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export theme config
|
* Export theme config
|
||||||
*/
|
*/
|
||||||
hexo.extend.helper.register('next_config', function() {
|
hexo.extend.helper.register('next_config', function() {
|
||||||
const { config, theme, url_for, __ } = this;
|
const { config, theme, url_for, __ } = this;
|
||||||
|
let hostname;
|
||||||
|
try {
|
||||||
|
hostname = new URL(config.url).hostname || config.url;
|
||||||
|
} catch {
|
||||||
|
hostname = config.url;
|
||||||
|
}
|
||||||
const exportConfig = {
|
const exportConfig = {
|
||||||
hostname : parse(config.url).hostname || config.url,
|
hostname,
|
||||||
root : config.root,
|
root : config.root,
|
||||||
images : url_for(theme.images),
|
images : url_for(theme.images),
|
||||||
scheme : theme.scheme,
|
scheme : theme.scheme,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user