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,