includable / react-native-check-version

🥕 Get the latest version of your app.
https://flexible.agency
MIT License
182 stars 22 forks source link

getting error on Android #54

Open mubashiralisiddiqui opened 11 months ago

mubashiralisiddiqui commented 11 months 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 11 months ago

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

adrienGzc commented 11 months 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 11 months 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 11 months ago

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

JrajsinhZala commented 1 month ago

const regexPattern = /"(\d+\.\d+\.\d+)\s+"/g;

I thing issue in current regex pattern i used below it's work for me

 const regexPattern = /"(\d+\.\d+\.\d+)\s+"/g;
 const versions = [...text.matchAll(regexPattern)].map(match => match[1])[0];
tschoffelen commented 1 month ago

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