-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
System info
Issue occurs on: Web
Plugin name: package_info_plus_web
Plugin version: 0.2.1
Flutter doctor output:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.23.0-18.1.pre, on Mac OS X 10.15.7 19H114 x86_64, locale it-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.51.0)
[✓] Connected device (2 available)
• No issues found!
Steps to Reproduce
When you use PackageInfo.fromPlatform() to get version info, there is an extra (forward) slash before the file name, like http://localhost:62124//version.json (port number can change).
If the application is deployed on a web server that doesn't change/redirect/correct the double slash in the URL (we used S3 static content deployment in AWS, that is one of these cases) the browser cannot get the version.json file (error 404) so the version number is not get.
You can get a test application here on gist.
- Create a new flutter application
- Add package_info_plus to pubspec.yaml
- Add a Text to the main screen populated using PackageInfo.fromPlatform()
- Run the application using Chrome profile and explore the network from the developer tools
- You can see the request http://localhost:62124//version.json to get the version file (port number could differ) instead of
the correct http://localhost:62124/version.json
Suggested fix
| '${Uri.parse(window.document.baseUri).removeFragment()}/version.json'; |
The slash should not be added since window.document.baseUri always ends with a slash (see the description for #32)
Added a PR for this: 97
Logs
In attach the log of the request from Chrome browser; you can see the double slash in the GET
GET //version.json HTTP/1.1
Host: localhost:62124
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36
Accept: */*
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:62124/
Accept-Encoding: gzip, deflate, br
Accept-Language: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7
If-None-Match: 760825325
Analyzing test_web...
No issues found! (ran in 3.2s)
[✓] Flutter (Channel beta, 1.23.0-18.1.pre, on Mac OS X 10.15.7 19H114 x86_64, locale it-IT)
• Flutter version 1.23.0-18.1.pre at /Users/Ciro/Dati/Sorgenti/_tools/flutter
• Framework revision 198df796aa (3 months ago), 2020-10-15 12:04:33 -0700
• Engine revision 1d12d82d9c
• Dart version 2.11.0 (build 2.11.0-213.1.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/ciro/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Users/ciro/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7042882/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.9.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Users/ciro/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7042882/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.51.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.96
• No issues found!