tschoffelen / react-native-check-version

🥕 Get the latest version of your app.
MIT License
190 stars 23 forks source link

getting error on Android #54

Open mubashiralisiddiqui opened 1 year ago

mubashiralisiddiqui commented 1 year ago

"react-native-check-version": "^1.1.1", "react-native": "0.66.5", { platform: 'android', bundleId: 'com.tntmobile', version: null, needsUpdate: false, notes: '', url: null, lastChecked: '2023-05-28T12:37:39.902Z', country: 'fr', error: [TypeError: Cannot convert null value to object] }

in node modules here is the issue const text = await res.text(); const version = text.match(/[[['"['"]]],/)[1]; getting null while applying the regex

adrienGzc commented 1 year ago

~~Hi, I got the same on my project "error": [TypeError: null is not an object (evaluating 'text.match(/\[\[\[['"]((\d+\.)+\d+)['"]\]\],/)[1]')]~~

adrienGzc commented 1 year ago

I actually found the issue for my case. My version number was 2.2.3 (XXX) displayed on the Google Play Store page. Without the (XXX) the regex works just fine. I change the regex to match my case and also work like before by adding this (\s\(\d+\))? so the regex now looks like this \[\[\[['"]((\d+\.)+\d+)(\s\(\d+\))?['"]\]\].

@tschoffelen are you interested in having the changes in your package? If so I can make a PR for the changes. Let me know 🙂

tschoffelen commented 1 year ago

Hi @adrienGzc! Good find!

Definitely happy to accept PRs. One thing to keep in mind though is that I don't think that's a valid semver, so might also need to see if that causes problems with the version comparison logic.

adrienGzc commented 1 year ago

Let me check how this behaves, I'll let you know 🙂

tschoffelen commented 6 months ago

If you're willing to open a PR with this change that would be amazing!