flutter-tool, web: update HTML template serviceWorkerVersion to be const (#124826)

flutter-tool, web: update HTML template serviceWorkerVersion to be const
This commit is contained in:
Kevin Moore
2023-04-13 19:01:21 -07:00
committed by GitHub
parent 4c41c0dbcd
commit 3bc07c1cef
4 changed files with 44 additions and 6 deletions

View File

@@ -70,8 +70,9 @@ class IndexHtml {
if (serviceWorkerVersion != null) {
_content = _content
.replaceFirst(
'var serviceWorkerVersion = null',
'var serviceWorkerVersion = "$serviceWorkerVersion"',
// Support older `var` syntax as well as new `const` syntax
RegExp('(const|var) serviceWorkerVersion = null'),
'const serviceWorkerVersion = "$serviceWorkerVersion"',
)
// This is for legacy index.html that still uses the old service
// worker loading mechanism.