From 8aa84d79f93fc34bedff7fa4f19a1d0d2f593ef2 Mon Sep 17 00:00:00 2001 From: Pilgrim Lyieu <80107081+pilgrimlyieu@users.noreply.github.com> Date: Wed, 6 May 2026 22:59:11 +0800 Subject: [PATCH] Replace deprecated `url.parse()` with WHATWG `URL` API (#955) --- scripts/helpers/next-config.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/helpers/next-config.js b/scripts/helpers/next-config.js index 9ba4659..be01d7e 100644 --- a/scripts/helpers/next-config.js +++ b/scripts/helpers/next-config.js @@ -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,