Replace deprecated url.parse() with WHATWG URL API (#955)

This commit is contained in:
Pilgrim Lyieu 2026-05-06 22:59:11 +08:00 committed by GitHub
parent b90614fba4
commit 8aa84d79f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,15 +2,19 @@
'use strict';
const { parse } = require('url');
/**
* Export theme config
*/
hexo.extend.helper.register('next_config', function() {
const { config, theme, url_for, __ } = this;
let hostname;
try {
hostname = new URL(config.url).hostname || config.url;
} catch {
hostname = config.url;
}
const exportConfig = {
hostname : parse(config.url).hostname || config.url,
hostname,
root : config.root,
images : url_for(theme.images),
scheme : theme.scheme,