Skip to content

Commit

Permalink
Avoid traversing undefined variables
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Nov 27, 2019
1 parent 7542558 commit 121760b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scripts/events/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function isObject(item) {
}

function merge(target, source) {
for (const key of Object.keys(source)) {
for (const key in source) {
if (isObject(target[key]) && isObject(source[key])) {
merge(target[key], source[key]);
} else {
Expand Down
6 changes: 2 additions & 4 deletions scripts/helpers/next-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const { htmlTag } = require('hexo-util');
const url = require('url');

hexo.extend.helper.register('next_url', function(path, text, options) {
hexo.extend.helper.register('next_url', function(path, text, options = {}) {
const { config } = this;
var data = url.parse(path);
var siteHost = url.parse(config.url).hostname || config.url;
Expand All @@ -26,9 +26,7 @@ hexo.extend.helper.register('next_url', function(path, text, options) {
};
}

options = options || {};

for (let key of Object.keys(options)) {
for (let key in options) {
/**
* If option have `class` attribute, add it to
* 'exturl' class if `exturl` option enabled.
Expand Down

0 comments on commit 121760b

Please sign in to comment.