larryaasen / upgrader

A Flutter package for prompting users to upgrade when there is a newer version of the app in the store.
MIT License
523 stars 258 forks source link

PlayStoreResults.redesignedVersion fails when the app name contains special characters like apostrophe #375

Closed aruhant closed 3 months ago

aruhant commented 5 months ago

The playstore results parser fails if the app title contains an apostrophe Like, McConald's, for example. This is because the special characters are unicode escaped and the parser fails to match the storename in the following line of code:

      final versionElement = additionalInfoElementsFiltered
          .where((element) => element.text.contains("\"${storeName}\""))

Let me know if any other info is needed or if I cam submit a PR with a fix.

upgrader: instantiated.
upgrader: initialize called
upgrader: build UpgradeAlert
upgrader: initializing
upgrader: default operatingSystem: android UQ1A.240105.002
upgrader: operatingSystem: android
upgrader: isAndroid: true, isIOS: false, isLinux: false, isMacOS: false, isWindows: false, isFuchsia: false, isWeb: false
upgrader: package info packageName: com.mcdonalds.app
upgrader: package info appName: McDonald's
upgrader: package info version: 1.0.0
upgrader: countryCode: US
upgrader: languageCode: en
upgrader: PlayStoreResults.redesignedVersion exception: Bad state: No element
upgrader: need to evaluate version
upgrader: blocked: false
upgrader: debugDisplayAlways: false
upgrader: debugDisplayOnce: false
upgrader: hasAlerted: false
upgrader: appStoreVersion: null
upgrader: installedVersion: 1.0.9999
upgrader: minAppVersion: null
upgrader: isUpdateAvailable: false
upgrader: shouldDisplayUpgrade: false
upgrader: shouldDisplayReleaseNotes: false
  upgrader:
    dependency: "direct main"
    description:
      name: upgrader
      sha256: d63081e43d1daa1d0e4f8177b56311523985ac77c25519d559040e3c14fb947e
      url: "https://pub.dev"
    source: hosted
    version: "8.4.0"
aruhant commented 5 months ago

I have submitted a PR to fix this. Kindly review and merge #376 when you get a chance.

larryaasen commented 3 months ago

@aruhant I created a unit test to show this failure and I was not able to get it to fail. I duplicated the test testing lookupById with redesignedVersion in file play_store_test.dart and changed the app id from com.testing.test4 to com.testing.test8, and duplicated the file test_play_store_page4.txt as test_play_store_page8.txt, and changed the title in 6 places throughout the file from:

US Debt Now - National Debt

to:

US Debt Now - “National’s” Debt

The test did not fail.

Can you put a unit test in your PR that shows it failing if run without your code change?

larryaasen commented 3 months ago

I fixed this issue and it will be available in the next release 10.1.0.