Skip to content

Commit 8aa84d7

Browse files
authored
Replace deprecated url.parse() with WHATWG URL API (#955)
1 parent b90614f commit 8aa84d7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

scripts/helpers/next-config.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22

33
'use strict';
44

5-
const { parse } = require('url');
6-
75
/**
86
* Export theme config
97
*/
108
hexo.extend.helper.register('next_config', function() {
119
const { config, theme, url_for, __ } = this;
10+
let hostname;
11+
try {
12+
hostname = new URL(config.url).hostname || config.url;
13+
} catch {
14+
hostname = config.url;
15+
}
1216
const exportConfig = {
13-
hostname : parse(config.url).hostname || config.url,
17+
hostname,
1418
root : config.root,
1519
images : url_for(theme.images),
1620
scheme : theme.scheme,

0 commit comments

Comments
 (0)