Skip to content

Commit

Permalink
fix: conditional of data is actually an object
Browse files Browse the repository at this point in the history
chore: add `Pattern` result `boolean` type
- PR hexojs/hexo-util/pull/311
- changes hexojs/hexo-util@9ddb7e2
  • Loading branch information
dimaslanjaka committed May 18, 2023
1 parent b33d7e7 commit a5aef69
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/plugins/filter/template_locals/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ function i18nLocalsFilter(locals) {
const pattern = new Pattern(`${i18nDir}/*path`);
const data = pattern.match(locals.path);

if (data && data.lang && i18nLanguages.includes(data.lang)) {
if (
typeof data !== 'undefined'
&& !Array.isArray(data)
&& typeof data !== 'boolean'
&& data.lang
&& i18nLanguages.includes(data.lang)
) {
lang = data.lang;
page.canonical_path = data.path;
} else {
Expand Down

0 comments on commit a5aef69

Please sign in to comment.