Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting error on Android #54

Open
mubashiralisiddiqui opened this issue May 29, 2023 · 6 comments
Open

getting error on Android #54

mubashiralisiddiqui opened this issue May 29, 2023 · 6 comments

Comments

@mubashiralisiddiqui
Copy link

"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
Copy link

adrienGzc commented Jun 9, 2023

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

@adrienGzc
Copy link

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
Copy link
Member

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
Copy link

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

@JrajsinhZala
Copy link

JrajsinhZala commented Mar 30, 2024

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants