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

fix: Android test RegExp can't match Android 10 or 10.1 and so on #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gitBingxu
Copy link

I found the bug on Huawei mate30 which userAgent is "... Android 10 ...", Qrcode.js can not get the correct android version on the device because of the reg.

I fixed it and checked it, there are test cases:

const TEST_CASE = [
    {source: 'android 0', expect: 0},
    {source: 'android 0.1', expect: 0.1},
    {source: 'android 0.1.1', expect: 0.1},
    {source: 'android 10', expect: 10},
    {source: 'android 10.0', expect: 10},
    {source: 'android 11.1', expect: 11.1},
    {source: 'android 11.09.1', expect: 11.09},
    {source: 'android 111.1.1', expect: 111.1}
]

const test = (reg) => {
    return TEST_CASE.every(item => {
        return Number.parseFloat(item.source.match(reg)[1]) === item.expect;
    })
}

test(/android (([0-9])+(\.[0-9]+)?)/i);   // true

Could you please approve it, I think the Qrcode.js is very usefull, Thank you guys~

@Wing-9527
Copy link

Wing-9527 commented Nov 22, 2022

reference issue #280

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

Successfully merging this pull request may close these issues.

2 participants