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

Check for empty tags #557

Merged
merged 3 commits into from
Jun 12, 2019
Merged

Check for empty tags #557

merged 3 commits into from
Jun 12, 2019

Conversation

edwardhorsford
Copy link
Contributor

Fixes #556 where empty tags causes the merge to fail.

Copy link
Contributor

@kleinfreund kleinfreund left a comment

Choose a reason for hiding this comment

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

This looks good to me. I just made a small remark about using else if in one place for performance reasons.

if (typeof data.tags === "string"){
data.tags = data.tags ? [data.tags] : [];
}
if (data.tags === null){
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be an else if since the conditions are mutually exclusive. When typeof data.tags === "string", the second condition is evaluated again even though it cannot be true.

@edwardhorsford
Copy link
Contributor Author

@kleinfreund thanks for looking so quickly. I've refactored it a bit so both checks are included. It sort of looked like the ternary check was trying to do this anyway - so I'm using that as well now.

@zachleat
Copy link
Member

zachleat commented Jun 12, 2019

Oh damn @edwardhorsford sorry to do this but I thought your original commit was actually much easier to read. Can you switch back to that and use an else if like @kleinfreund suggested? (Sorry!)

Otherwise this is a 👍 from me

@zachleat zachleat added the needs-changes A pull request that requires additional changes before it can be merged. label Jun 12, 2019
@edwardhorsford
Copy link
Contributor Author

@zachleat Updated as requested.

It probably wants tests, but I'm not familiar with adding those, sorry.

I also don't know if there's other stuff that gets merged that should also check for empty.

@zachleat zachleat merged commit 7d1459e into 11ty:master Jun 12, 2019
@zachleat zachleat removed the needs-changes A pull request that requires additional changes before it can be merged. label Jun 12, 2019
@zachleat zachleat added this to the Next Minor Version milestone Jun 12, 2019
@zachleat
Copy link
Member

Thank you @edwardhorsford!!

zachleat added a commit that referenced this pull request Jun 12, 2019
@zachleat
Copy link
Member

Just added a test for this in f014f56 if you’d like to have a look @edwardhorsford (it’s one line 😇)

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.

Empty tags in post causes merge failure.
3 participants