Skip to content

Commit

Permalink
task: added checking if attr object has any content (#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
finnar-bin authored Jan 19, 2023
1 parent e18cda2 commit 9843814
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/shell/store/headTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export function headTags(state = [], action) {
// Transform attributes into an array structure.
// Also helpful for maintaining order
function transformAttributes(attrs) {
if (!Object.keys(attrs).length) {
return {};
}

return Object.keys(attrs).map((key) => {
return {
key: key,
Expand Down Expand Up @@ -163,7 +167,7 @@ export const createHeadTag = (tag) => {
body: tag,
}).then((res) => {
if (!res.data.error) {
res.data.attributes = transformAttributes(res.data.attributes);
res.data.attributes = transformAttributes(res.data?.attributes);
dispatch({
type: "ADD_HEADTAG",
tag: res.data,
Expand Down

0 comments on commit 9843814

Please sign in to comment.