Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(permalink): handle invalid permalink setting #384

Merged
merged 2 commits into from
Dec 23, 2023
Merged

fix(permalink): handle invalid permalink setting #384

merged 2 commits into from
Dec 23, 2023

Conversation

stevenjoezhang
Copy link
Member

@coveralls
Copy link

coveralls commented Oct 21, 2023

Coverage Status

coverage: 96.751% (+0.01%) from 96.74% when pulling 919132a on permalink into ec7fd7c on master.

D-Sketon
D-Sketon previously approved these changes Oct 21, 2023
uiolee
uiolee previously approved these changes Oct 22, 2023
return this.rule.replace(rParam, (match, name) => data[name]);
return this.rule.replace(rParam, (match, name) => {
if (['permalink', 'path'].includes(name)) {
throw new Error('Invalid permalink setting!');
Copy link
Member

@uiolee uiolee Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not the best change, it makes hexo-util and hexo being coupled. (Although probably no one uses hexo-util except hexo)

hexo-util/README.md

Lines 404 to 405 in ec7fd7c

permalink.stringify({year: '2014', month: '01', day: '31', title: 'test'})
// 2014/01/31/test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the patch to disallow the case where the parameter is a getter. Please take a look to see if this is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the patch to disallow the case where the parameter is a getter. Please take a look to see if this is better.

This may affect :tags and :categories, but maybe no one will use these two parameters because they can't be overridden by front-matter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work. it looks better than before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:tags or :categories looks like an array

@uiolee uiolee requested review from uiolee and removed request for uiolee October 22, 2023 05:27
@stevenjoezhang stevenjoezhang dismissed stale reviews from uiolee and D-Sketon via 919132a October 22, 2023 07:11
@uiolee uiolee merged commit 092daf6 into master Dec 23, 2023
24 checks passed
@uiolee uiolee deleted the permalink branch December 23, 2023 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when specifying :path in permalink: RangeError: Maximum call stack size exceeded
4 participants