pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.18k stars 3.62k forks source link

Fix version extraction in LocalWebCache.js to handle null match #3214

Closed rniedson closed 2 months ago

rniedson commented 2 months ago

This pull request addresses an issue where the version extraction in LocalWebCache.js can throw an error if the regex match returns null. This fix ensures that the code safely handles null matches, preventing a TypeError.

PR Details

Description

This change updates the version extraction logic in the persist method to safely handle cases where the regex match returns null. This prevents the TypeError caused by trying to access properties of null.

Related Issue

Motivation and Context

This change is required to make the version extraction process more robust and to prevent crashes when the manifest version is not found in the index.html.

How Has This Been Tested

This change has been tested by running the modified code and ensuring that it handles cases where the version is not found in the index.html without throwing errors.

Types of changes

Checklist

alechkos commented 2 months ago

2816