Skip to content

Commit

Permalink
chore: prevent js crashes from null value in messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdeus committed Nov 18, 2024
1 parent 093d48d commit 4727179
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion decidim-core/app/packs/src/decidim/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export const getMessages = (key = null) => {
* @returns {Object} The converted dictionary object
*/
export const createDictionary = (messages, prefix = "") => {
if (!messages) return {};

Check failure on line 28 in decidim-core/app/packs/src/decidim/i18n.js

View workflow job for this annotation

GitHub Actions / Lint code (npm run lint)

Expected { after 'if' condition

let final = {};
Object.keys(messages).forEach((key) => {
if (typeof messages[key] === "object") {
if (messages[key] && typeof messages[key] === "object") {
final = { ...final, ...createDictionary(messages[key], `${prefix}${key}.`) };
} else if (key === "") {
final[prefix?.replace(/\.$/, "") || ""] = messages[key];
Expand Down

0 comments on commit 4727179

Please sign in to comment.