mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
Meta: Download imports and src assignments
Resources referenced in imports and src assignments now also get downloaded by the WPT import script.
This commit is contained in:
committed by
Shannon Booth
parent
8053c2a0f1
commit
2362a65e3b
Notes:
github-actions[bot]
2026-04-03 19:22:33 +00:00
Author: https://github.com/skyz1 Commit: https://github.com/LadybirdBrowser/ladybird/commit/2362a65e3bf Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6029 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/konradekk Reviewed-by: https://github.com/shannonbooth ✅
@@ -73,7 +73,10 @@ class LinkedResourceFinder(HTMLParser):
|
||||
self._match_css_url_ = re.compile(r"url\(['\"]?(?P<url>[^'\")]+)['\"]?\)")
|
||||
self._match_css_import_string_ = re.compile(r"@import\s+\"(?P<url>[^\")]+)\"")
|
||||
self._match_fetch_import_path = re.compile(r"fetch\((\"|\')(?P<url>.*)(\"|\')\)")
|
||||
self._match_worker_import_path = re.compile(r"Worker\(\"(?P<url>.*)\"\)")
|
||||
self._match_import_call = re.compile(r"import\(['\"](?P<url>.*?)['\"].*\)")
|
||||
self._match_import_statement = re.compile(r"import (.*? from )?['\"](?P<url>.*?)['\"]")
|
||||
self._match_src_assignment = re.compile(r"\.src ?= ?['\"](?P<url>.*?)['\"]")
|
||||
self._match_worker_import_path = re.compile(r"Worker\(['\"](?P<url>.*)['\"]\)")
|
||||
self._resources = set()
|
||||
|
||||
@property
|
||||
@@ -116,6 +119,21 @@ class LinkedResourceFinder(HTMLParser):
|
||||
for match in fetch_iterator:
|
||||
self._resources.add(match.group("url"))
|
||||
|
||||
# Look for uses of import()
|
||||
import_call_iterator = self._match_import_call.finditer(data)
|
||||
for match in import_call_iterator:
|
||||
self._resources.add(match.group("url"))
|
||||
|
||||
# Look for uses of import statements
|
||||
import_statement_iterator = self._match_import_statement.finditer(data)
|
||||
for match in import_statement_iterator:
|
||||
self._resources.add(match.group("url"))
|
||||
|
||||
# Look for uses of .src = "..."
|
||||
src_assignment_iterator = self._match_src_assignment.finditer(data)
|
||||
for match in src_assignment_iterator:
|
||||
self._resources.add(match.group("url"))
|
||||
|
||||
# Look for uses of Worker()
|
||||
filepath_iterator = self._match_worker_import_path.finditer(data)
|
||||
for match in filepath_iterator:
|
||||
|
||||
Reference in New Issue
Block a user